DEVFYI - Developer Resource - FYI

What is weak reference in Java

Java Interview Questions and Answers (part 1)

(Continued from previous question...)

161. What is weak reference in Java

A weak reference is one that does not prevent the referenced object from being garbage collected. You might use them to manage a HashMap to look up a cache of objects. A weak reference is a reference that does not keep the object it refers to alive. A weak reference is not counted as a reference in garbage collection. If the object is not referred to elsewhere as well, it will be garbage collected.

(Continued on next question...)

Other Interview Questions