Use the following command to generate a window input dialog
String myString=JOptionPane.showInputDialog("Enter a number: ");
use the following command to convert a string to a number
int myNumber = Integer.parseInt(myString);
and finally use the following command to print the input number to the console
System.out.println("The number is "+ myNumber);
Don't forget the following import command
import javax.swing.JOptionPane;
so that Java can recognize JOptionPane library.
4 則留言:
電子二甲9326145陳鵬壬
終於好了~~!!
電子二甲9326145陳鵬壬
更改過的,應該ok了吧!!
9224205 江昇祐 Java Homework4
電子三丙 高志遠 9226307
張貼留言