What is WeakHashMap?
java.util.HashMap has strong key reference, even if the key is garbage collected also we can use the entry in the HashMap. But in the case of java.util.WeakHashMap key reference is very weak as its name says. Here is one simple example to store values in both HashMap and WeakHashMap and making key as null.. see the results.
Hashmap after creation :Santhosh
Hashmap after key is null :Santhosh
WeakHashMap after creation :Santhosh
WeakHashMap after key is null :null