Is there any solution for destroying current instance of object in itself ?
I am looking for something which looks like:
class KillMe {
....
public void destroy() {
this.getObject = null //this is only for demonstrate my idea
}
....
}
Java objects live until there are no longer any references to them. Since an object cannot determine how many references there are to itself, an object cannot “destroy itself”.