-1
嗨,大家好,請讓我知道我錯了,而試圖喲運行該程序並獲得java.lang.NumberFormatException
錯誤Java輸入輸出測試通過GUI
import javax.swing.*;
public class InputOutputTest {
public static void main(String[] args) {
//takes input through GUI
String input = JOptionPane.showInputDialog("Enternumber");
int number = Integer.parseInt(input);
int square = number * number;
//Display square on console
System.out.println("square:" + square);
//Display square on GUI
JOptionPane.showMessageDialog(null, "square:"+ square);
System.exit(0);
}
}
在'InputDialog'中輸入數字。它不得包含任何字母或符號字符。 – asissuthar