What's the easiest way to get a distinct list of the objects using only a subset of the object's properties? I don't want to override the equals and hashCode method because this measure of object equality (i.e., a subset of the properties) is only applicable in a few use cases. Is one collection type best suited for this purpose?
Asked
Active
Viewed 355 times
1 Answers
3
Create a TreeSet and add a custom comparator that compares objects based on the subset of properties that determine uniqueness. Then add all the objects to that treeset.

MeBigFatGuy
- 28,272
- 7
- 61
- 66