java中的软引用与虚引用--------java中的四大引用

强引用

首先我先建了一个类M 查看何时调用 finalize方法ide

public class M {
@Override
protected void finalize() throws Throwable {code

System.out.println("~finalize");

super.finalize();
}
}orm

public class NormalReference {io

public static void main(String[] args) throws IOException {
    M m = new M();

m=null;
System.gc();
System.out.println(m);
System.in.read();
}
}class

相关文章
相关标签/搜索