乐趣区

关于java:java中的软引用与虚引用java中的四大引用

强援用

首先我先建了一个类 M 查看什么时候调用 finalize 办法

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

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

super.finalize();
}
}

public class NormalReference {

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

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

退出移动版