JAVA程序中的错误

来源:百度知道 编辑:UC知道 时间:2024/06/21 09:25:07
Exception in thread "main" java.lang.NullPointerException
at ABMSMain.<init>(ABMS02.java:66)
at ABMS02.main(ABMS02.java:160)
是在程序加入下面代码后产生的
f.setResizable(true);
f.setSize(1000,700);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocation(140,50);

空指针错误
抛这种NullPointerException
说明你有变量没有初始化就使用啦,就是说没有new出来就使用啦
看看你的f有没有初始化。

ABMS02.java:66
检查这行的代码。。

f是个变量还是对象?就是问你有没有被实例化。

F为NULL