Difference between IdentityHashMap and HashMap in Java? Example
IdentityHashMap in Java was added in Java 1.4 but still, it's one of those lesser-known classes in Java. The main difference between IdentityHashMap and HashMap in Java is that IdentityHashMap is a special implementation of Map interface which doesn't use equals() and hashCode() method for comparing objects unlike other implementations of Map e.g. HashMap. Instead, IdentityHashMap uses the equality operator "==" to compare keys and values in Java which makes it faster compared to HashMap and suitable where you need reference equality check and instead of logical equality.
تعليقات
إرسال تعليق