I have 2 ArrayList of custom objects. I want to remove duplicate entries from both the ArrayList.
The objects have three fields: fName, lName, and id. If the id occurs multiple times, I want to remove from both the lists.
How can I do that?
I am fine with merging both the lists and removing the 2 duplicate entries as well.
If you want to merge: simply copy the content of both lists to a map. Then you don’t have the duplicates anymore (but you loose your actual ordering):