Is there any way to override the the equals
method used by a Set
datatype? I wrote a custom equals
method for a class called Fee
Set
uses the equals method of the object added to the set. The JavaDoc states
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.
The Set.equals()
method is only used to compare two sets for equality. It's never used as part of adding/remove items from the set.