1.

What Is A Weakhashmap?

Answer»

WEAKHASHMAP is a Hash table based implementation of the Map interface, with weak keys. An entry in a WeakHashMap will automatically be REMOVED when its key is no longer in ordinary use. Which MEANS storing only weak references allows GARBAGE collector to remove the entry (key-value PAIR) from the map when its key is not referenced outside of the WeakHashMap.

In WeakHashMap both null values and the null key are supported. A WeakHashMap is created as- 

Map weakHashMap = new WeakHashMap();

WeakHashMap is a Hash table based implementation of the Map interface, with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. Which means storing only weak references allows garbage collector to remove the entry (key-value pair) from the map when its key is not referenced outside of the WeakHashMap.

In WeakHashMap both null values and the null key are supported. A WeakHashMap is created as- 

Map weakHashMap = new WeakHashMap();



Discussion

No Comment Found