如何破坏对象本身 [英] How to destroy object in itself

查看:129
本文介绍了如何破坏对象本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何破坏当前对象实例的解决方案?

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对象存在,直到不再引用它们为止。由于对象无法确定自身有多少引用,因此对象不能自我毁灭。

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".

这篇关于如何破坏对象本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆