Java defines the Set interface, where contains() is defined as follows:
Returns true if this set contains the specified element. More formally returns true if and only if this set contains an element e such that (o==null ? e==null : o.equals(e)) .
The Collection interface defines contains() as follows:
Returns true if this collection contains the specified item. More formally, it returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e)) .
I need a set of Java instances where contains() based on == , not equals() . In other words, a set of hard instances, where two different objects are A and B, where A.equals(B) can coexist in the same set, since A!=B
Is such a โset of instancesโ shipped in Java or in some public library? I canโt find anything, but maybe someone knows better. If not, I will implement it. Thanks.
source share