以下一些Java課程初學者水平,到了這個問題:JOptionPane.showMessageDialog無效AnnotationName
Multiple markers at this line
- Syntax error on token "showMessageDialog", invalid
AnnotationName
- Syntax error on token "(", { expected after this token
- Syntax error on tokens, ConstructorHeaderName expected instead
而行是:
JOptionPane.showMessageDialog(null, "The answer is " +sum, "The Title", JOptionPane.INFORMATION_MESSAGE);
Java文檔說,這個方法接受4參數,可以讓我我正在發送4個參數。此外,我已導入所需的庫:
import javax.swing.JOptionPane;
JOptionPane.showInputDialog
工程確定,但不JOptionPane.showMessageDialog
。我錯過了什麼? 謝謝。
全碼
package java_practice;
import javax.swing.JOptionPane;
public class GraphicalUserInterface {
String first_number = JOptionPane.showInputDialog("Enter first number");
String second_number = JOptionPane.showInputDialog("Enter second number");
int num1 = Integer.parseInt(first_number);
int num2 = Integer.parseInt(second_number);
int sum = num1 + num2;
JOptionPane.showMessageDialog(null, "The answer is " +sum, "The Title", JOptionPane.INFORMATION_MESSAGE);
}
報告錯誤的人之前是什麼......? – Adam
@亞當我會把代碼.. 1時刻。 – rmagnum2002
是你的代碼.do裏面有一個方法 –