0
这是我的代码,当我运行这个例子时,它给出NullPointerException
你能帮我找到错误或为什么我有这个异常! 我的代码:为什么我得到NullPointerException
public class Frame extends JFrame
{
public Frame()
{
JLabel label;
label.setText("test");
add(label);
setSize(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new Frame().setVisible(true);
}
}
你能提供堆栈跟踪吗? – 2015-01-04 12:57:10
另请参阅http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors – 2015-01-04 12:58:08
JLabel label =新的JLabel(); label.setText( “测试”); – Xcihnegn 2015-01-04 12:59:27