Java / Object, Class and Package
What happens when equals() is not consistent with compareTo() method?
java.util.Set implementations such as SortedSet, TreeSet uses compareTo method for comparing objects. When compareTo does not return 0 while equals is true, it breaks Set contract and may result in duplicates.
More Related questions...