Programming Languages
Java
Subjective
Sep 24, 2025
Explain the concept of weak references in Java.
Detailed Explanation
Weak references allow referencing an object without preventing garbage collection. Types: WeakReference (basic weak reference), SoftReference (cleared when memory is low), PhantomReference (for cleanup actions). Used in caches, listeners, avoiding memory leaks. WeakHashMap uses weak references for keys.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts