Let's say I have two Arraylists.
a.add("Isabella");
a.add("Angelina");
a.add("Pille");
a.add("Hazem");
b.add("Isabella");
b.add("Angelina");
b.add("Bianca");
a.retainAll(b);
This should give me Arraylist a with the following elements: Isabella, Angelina, Pille, Hazem
. But, when I try a.size()
I get 0. Why?
My output:
[DEBUG] The Karate Kid
[DEBUG] The Day the Earth Stood Still
[DEBUG] The Pursuit of Happyness
[DEBUG] Justin Bieber: Never Say Never
[DEBUG] After Earth
[DEBUG] Independence Day
[DEBUG] Men in Black
[DEBUG] Men in Black II
[DEBUG] Hancock
[DEBUG] Shark Tale
[DEBUG] Made in America
[DEBUG] Six Degrees of Separation
[DEBUG] Jersey Girl
[DEBUG] The Legend of Bagger Vance
[DEBUG] Men in Black 3
[DEBUG] Seven Pounds
[DEBUG] Bad Boys II
[DEBUG] Bad Boys 3
[DEBUG] Enemy of the State
[DEBUG] Wild Wild West
[DEBUG] Hitch
[DEBUG] Ali
[DEBUG] I, Robot
[DEBUG] Live 8
[DEBUG] Where The Day Takes You
[DEBUG] Independence Day 3
[DEBUG] I, Robot 2
[DEBUG] The Pursuit of Happyness
[DEBUG] I Am Legend
[DEBUG] Independence Day 2
[DEBUG] After Earth
[DEBUG] Bad Boys
[DEBUG] Partners in Time: The Making of MIB 3
[DEBUG] David Blaine: Real or Magic
[DEBUG] Size: 0
The first part are films starring Jaden Smith, and second are films starring Will Smith, I want only films that have both. Is retainAll()
the best method for this kind of work?