ガベージコレクターがオブジェクトを削除するためのシグナルを残して、その参照変数を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.
}
}
}