I have an ArrayList
:
Arraylist<Person> list1 = new ArrayList<Person>();
list1.add(new Person("John", 0));
list1.add(new Person("Kane", 0));
list1.add(new Person("Jen", 0));
And another ArrayList
:
Arraylist<Person> list2 = new ArrayList<Person>();
list2.add(new Person("John", 2));
list2.add(new Person("Kane", 4));
I want the resulting ArrayList
to contain:
("John", 2) ("Kane", 4) ("Jen", 0)
I want to merge these two lists and remove the ones that have the value 0. If I did
list2.addAll(list1)
, then list2
has two entries for "John" with the values of 2 and 0. I want to remove the entry with the value of 0 from this list.