2
cb219
4y

Struggled whole day to remove duplicate objects from a list in java. Those objects (of a custom class) contain a unique id, the remaining properties can be identical across list items.
Wondered why hashset.add() always returns true and thus duplicates are still inserted.
Little did I forget about things like equals() and hashCode() 🤦

Comments
  • 3
    Yeah, the default implementation is hidden and you never think about changing it :')

    Anyway glad you solved.
Add Comment