How does the difference in Guava settings work?

when two objects are considered different c Sets.difference. When they have a different hash code or when it object.equalsreturns false.

+4
source share
1 answer

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() - () , -.

+9

All Articles