Ordinary Maps use the following test for equality (k1==null ? k2==null : k1.equals(k2)).) IdentityHashMap uses k1==k2. My question is that even Object's equals() method returns k1==k2. Only when the Object's equals method is overridden inside a class, does it perform content based equality comparison. So, IdentityHashMap could have used Object's equals method for doing this. Is it right ? (It probably doesn't because it extends AbstractMap which already defines equals to perform content based comparison, not reference based.)
daudiam
-6
Junior Poster
Recommended Answers
Jump to PostIt probably doesn't because it extends AbstractMap which already defines equals to perform content based comparison, not reference based.
AbstractMap defines the equals method based on which Maps, extending it can be compared. It seems to me that you are confusing it with the equals() method of the 'keys' which …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.