执行GC程序时,我收到NPE错误,有人可以纠正我吗?

时间:2018-06-17 05:44:48

标签: java nullpointerexception

package com.java.gc;

公共类FinalizeDemo {     static FinalizeDemo s;

public static void main(String[] args) throws InterruptedException
{
    FinalizeDemo f = new FinalizeDemo();
    System.out.println("f hashcode:" +f.hashCode());
    f=null;
    System.gc();
    Thread.sleep(5000);

    System.out.println("s hashcode:"+s.hashCode());
    s=null;
    Thread.sleep(10000);
    System.out.println("ENd of main");

}
public void finlaize()
{
    System.out.println("Finlaize method called");
    s=this;
}

}

在运行此代码时获取NPE,有人可以帮助我吗?

0 个答案:

没有答案