JAVA错误:Exception in thread "main" java.lang.NullPointerException

时间:2022-02-23 20:46:27

JAVA错误:Exception in thread "main" java.lang.NullPointerException
例如:

Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at chuangti.Example1.CreateJFrame(Example1.java:41)
at chuangti.Example1.main(Example1.java:84)

解答 

java.lang.NullPointerException //即指针指向为空
at javax.swing.ImageIcon.<init>(Unknown Source) //为空的区域
at chuangti.Example1.CreateJFrame(Example1.java:41) //41行
at chuangti.Example1.main(Example1.java:84) //84行