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 contain:
("John", 2) ("Kane", 4) ("Jen", 0)
I want to combine these two lists and delete the ones that have the value 0. If I did list2.addAll(list1) , then list2 has two entries for "John" with values 2 and 0. I want to delete the entry with the value 0 from this list.
Harry source share