首页 > 其他 > 详细

对象销毁之前进行某些操作

时间:2014-08-13 17:49:26      阅读:277      评论:0      收藏:0      [点我收藏+]

class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String toString() {
        return "Nmae:" + this.name + ",Age:" + this.age;
    }

    public void finalize() {
        System.out.println("Object be released---->" + this);
    }
}

public class SystemDemo04 {
    public static void main(String[] args) {
        Person person = new Person("VON KENMO", 38);
        person = null;
        System.gc();
    }
}

对象销毁之前进行某些操作,布布扣,bubuko.com

对象销毁之前进行某些操作

原文:http://www.cnblogs.com/vonk/p/3910214.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!