Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

How IdentityHashMap is different from a regular Map in Java?

Pragya Keshap answered on February 4, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Java Creating WeakHashMap from Other Maps
  • Implementation of LinkedHashMap Class in Java map
  • What are the main differences between HashMap and ConcurrentHashMap in Java?
  • Java Creating LinkedHashMap from Other Maps
  • Java Creating ConcurrentHashMap from Other Maps
  • what is an identity hashmap
  • What is the main use of IdentityHashMap?

  • How IdentityHashMap is different from a regular Map in Java?

    0

    IndentityHashMap in Java implements Map interface. But it is not a

    general purpose implementation. It violates the general contract of

    Map interface by a different implementation of equals() method.

    In an IdentityHashMap, two keys k1 and k2 are equal if and only if

    (k1==k2). (In a normal Map implementation (like HashMap) two

    keys k1 and k2 are considered equal if and only if (k1==null ?

    k2==null : k1.equals(k2)).)

    It implements the Map interface with a hash table, using referenceequality in place of object-equality when comparing keys (and

    values).

    https://www.javatpoint.com/identityhashmap-class-in-java#:~:text=Difference%20Between%20IdentityHashMap%20and%20HashMap,is%20faster%20than%20the%20HashMap.

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: java map
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.