IdentityHashMap is exactly same as HashMap except the following difference.
In the HashMap JVM uses equals() method to identify duplicate keys but in the case of IdentityHashMap JVM uses == operator for this.
WeakHashMap is exactly same as HashMap except the following difference.
In case of HashMap an Object is not eligible for garbage collection if it is associated with HashMap even though it doesn't have any external references. ie HashMap dominates garbage collector.
But in case of WeakHashMap , if an Object is not having any external references then it is always eligible for garbage collection even though it is associated with weakHashMap. ie garbage collector dominates WeakHashMap
In the HashMap JVM uses equals() method to identify duplicate keys but in the case of IdentityHashMap JVM uses == operator for this.
WeakHashMap is exactly same as HashMap except the following difference.
In case of HashMap an Object is not eligible for garbage collection if it is associated with HashMap even though it doesn't have any external references. ie HashMap dominates garbage collector.
But in case of WeakHashMap , if an Object is not having any external references then it is always eligible for garbage collection even though it is associated with weakHashMap. ie garbage collector dominates WeakHashMap
No comments:
Post a Comment