我使用Swing在Java中制作了以下基本GUI程序。我从新波士顿的第一个Java GUI教程中获得了它。我已经检查和代码是完全一样的,但我总是得到以下错误:新波士顿GUI - 编译错误
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at gui.gui_1.main(gui_1.java:4)
这里是我的代码:
import javax.swing.JOptionPane;
class gui_1{
public static void main(String[] args){
String fn =JOptionPane.showInputDialog("enter first number");
String sn =JOptionPane.showInputDialog("enter second number");
int num1 = Integer.parseInt(fn);
int num2 = Integer.parseInt(sn);
int sum = num1 + num2;
JOptionPane.showMessageDialog(null, "the answer is "+ sum, "the title", JOptionPane.PLAIN_MESSAGE);
}
}
请告诉我,如果你已经看到了这qeustion但不能在评论中回答 –
您的代码是正确的。如何编译你的项目? –