The uniqueness of an item in HashSets is ultimately determined by the equals() method of the underlying object. See these references in JDK to a comment and the specific code.