How to create a list of unique/distinct objects (no duplicates) in Java?
Right now I am using HashMap
to do this as the key is o
You may want to use one of the implementing class of java.util.Set
Interface e.g. java.util.HashSet
collection class.
A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.