I have an object in a LinkedHashSet
that implements equals
, hashCode
and compareTo
(in a superclass) but when I try to remove that exact object from the set set.remove(obj)
the remove method returns false
and the object remains in the set. Is the implementation of LinkedHashSet
supposed to call the equals()
method of its objects? Because it doesn't. Could this be a java bug? I'm running 1.6.0_25.
My guess would be that your object's hashCode()
implementation is returning a different value than when you added the object to the set.