Quantcast
Channel: How do I go through 2 list and check if the content of one element in the same as another element in a different list? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Jitin Kodian for How do I go through 2 list and check if the content of one element in the same as another element in a different list?

$
0
0

Same as @Ahmed Raaj.

else{        List<Actor> movieActors = x.getListOfActors();              List<Actor> duplicateActors = new ArrayList<>();        List<Actor> uniqueActors = new ArrayList<>();        for(Actor eachActor : movieActor){            if(actors.contains(eachActor))                duplicateActors.add(eachActor);            else                uniqueActors.add(eachActor);        }        for(Actor eachDuplicateActor : duplicateActors){            for(Actor eachOriginalActors : actors){                if(eachOriginalActors.getName().equals(eachDuplicateActor.getName())                        eachOriginalActors.addCount();            }        }        actors.addAll(uniqueActors);    }

I haven't tested the code, so there might be errors


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>