I was going through WeakHashMap
in Java. And what I have understood is WeakHashMap
is exactly as HashMap
except its key references are WeakReference
. That means key references are eligible for gc
, and when it is garbaged, its entry will be removed from the map. This is not available in HashMap
. Please correct me if I am wrong.
I have one question over here.
Now in future If I get a requirement that I have to use Map for putting key and value,can I go forward with WeakHashMap
? Or do I need to consider any scenario where WeakHashMap
wont be fit only HashMap
will fit?