Jared Malcolm wrote:I think you may misunderstand GC.
Peeyush Bhadola wrote:At line#10: c3 = null. So there is no object present to be marked for GC.
Jared Malcolm wrote:if an object no longer has a reference pointing to it...that's the point at which it is ELIGIBLE to become GC'd
Peeyush Bhadola wrote:At line#11: c1 = null. That means the remote control(reference) c1 is not pointing to any object and hence the object created at line#8 can be marked for GC.