Grokking Java Interview Questions
Vote

0% completed

​

Strong, Soft, Weak, and Phantom References

ReferenceClassCan get() return the object?The collector may free the object
StrongNone, an ordinary variable or fieldNot neededNever, while the reference is reachable
SoftSoftReferenceYes, until it is clearedWhen memory is needed
WeakWeakReferenceYes, until it is clearedAt any collection
PhantomPhantomReferenceNeverAt any collection

The last column assumes that no stronger reference leads to the object. The three classes are in the package `java.lang.ref

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content