Collection framework series in Java - WeakHashMap in java- Explained in Detail
HTML-код
- Опубликовано: 10 сен 2024
- You can learn Java with me as the Java Programming language is being made easily. It would take a period of minimum three months and maximum 6 months to master Java. I would recommend you to watch all my videos to crack any software interviews that would require Java Programming language as a primary skill.
WeakHaspMap in Java :-
=====================
WeakHashMap is exactly similar to the HashMap but there is a difference with respect to key.
The keys of the HashMap are of Strong reference and the keys of the WeakHashMap are of weak references.
HashMap---Strong references
WeakHashMap---Weak references
The HashMap will ensure that the keys are not Garbage collected
The WeakHashMap will not protect it keys from the Garbage collection.