The javadoc says:
The returned set contains all elements contained in set1and not contained inset2
Thus, this means that the rule depends on the type of two sets. If Set is a HashSet, for example, is used equals(). If the set is a TreeSet, the method compareTo()(or the comparator method compare()) will be used . If IdentityHashSet is used, the identifier of the object will be used.
hashCode() - () , -.