When Is The Object Eligible For Garbage Collection?

后端 未结 7 675
后悔当初
后悔当初 2020-11-27 07:22

In the code below, given that amethod has been called. At what point/line is the Object originally referenced by myObject, eligible for Garbage Col

7条回答
  •  佛祖请我去吃肉
    2020-11-27 08:01

    From Book OCA Java SE 7

    An object is marked as eligible to be garbage collected when it can no longer be accessed, which can happen when the object goes out of scope. It can also happen when an object’s reference variable is assigned an explicit null value or is reinitialized.

提交回复
热议问题