Google News
logo
Java Collections - Interview Questions
What is IdentityHashmap in Java?
Java.util.IdentityHashMap implements Map interface and it does not make use of equals() and hashcode() methods to compare objects insteadIdentityHashMap uses equality operator "==" to compare the key and value objects.
 
The use of the equality operator makes IdentityHashMap perform faster compared to the HashMap and it suits the need where reference equality check is required rather than the logical semantics.
 
IdentityHashMap is not synchronized.
 
Although this class implements the Map interface, it violates the general contract that mandates the use of equals method when comparing key/value objects.
 
This Api is introduced as part of Java 1.4.
Advertisement