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
Browsing latest articles
Browse All 7 View Live

Answer by Maurice Perry for How do I go through 2 list and check if the...

I think you should reverse the order of the loops, and only add the actor if it is not found:for(int n = 0 ; n <movieActors.size();n++){ boolean found = false; for(int z = 0 ; z <actors.size();...

View Article



Answer by Jitin Kodian for How do I go through 2 list and check if the...

Same as @Ahmed Raaj. else{ List<Actor> movieActors = x.getListOfActors(); List<Actor> duplicateActors = new ArrayList<>(); List<Actor> uniqueActors = new ArrayList<>();...

View Article

Answer by Ahmed Raaj for How do I go through 2 list and check if the content...

Remove every thing from else condition and replace with following code. Though its not an optimal solution but might serve your purpose.else { List<Actor> movieActors = (List<Actor>)...

View Article

Answer by Naman for How do I go through 2 list and check if the content of...

Few open points --One, I would suggest using foreach for DS like List to iterate through.Take a look at How does the Java 'for each' loop work?Two, use equals to compare strings. Help - How do I...

View Article

Answer by Syed Daniyal Nasir for How do I go through 2 list and check if the...

Use the ".equals" instead of "=="

View Article


Answer by xitter for How do I go through 2 list and check if the content of...

When you do actors.get(z).getName() == movieActors.get(n).getName()I suppose name is a string, in that case it will not be true for same names. You need to do...

View Article

How do I go through 2 list and check if the content of one element in the...

private List<Actor> actors = new ArrayList<>();public void addActors(Movie x){if(actors.isEmpty()){ actors.addAll(x.getListOfActors());}else{ List<Actor> movieActors =...

View Article
Browsing latest articles
Browse All 7 View Live




Latest Images