我知道如何通过将对象的引用变量设置为 null 来为垃圾收集器留下删除对象的信号:
Player player_reference = new Player();
player_reference = null;
// Now the Garbage collector knows to release all the memory related to this object.
但是如何通过对象的类将引用变量设置为 null 呢?
class Player {
public void doSomthing() {
if(condition) {
// some code which set the reference variable to null.
}
}
}