|
Java™ by example!
|
|
|
What is a weak reference and when do I use one?
A WeakReference is a type of a reference object that allows you to determine when an object is being finalized. It allows you to keep a reference to the object without preventing it from being garbage-collected. They are used with caching and also provide an alternative to the cleanup typically done in Java finalization. Main.java:
outputs:
Further Information
Author of answer: Joris Van den Bogaert
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|