I\'ve got a List
of Persons and I want to find duplicate entries, consindering all fields except id
. So using the equals()
-method (and in
You can use Java HashMap
using
pairs. Map
. Also, some form of Comparator implementation to go with. If you check with containsKey or containsValue methods and find out you already have something (i.e. you are trying to add a duplicate, keep them in your original list. Otherwise, pop them out. In this way, you will end up with a list with the elements that were duplicates in your original list. TreeSet<,>will be another option, but I haven't used it yet so cannot offer advice.