2005-10-17

Lab JOptionPane(Java視窗input)

/*JOptionPane可以做Input&Output等動作*/

import javax.swing.JOptionPane;
//必須先匯入此項,swing為圖像

public class yusj
{
public static void main(String[] args)
{
String firstString=JOptionPane.showInputDialog("enter a number:");
//將所輸入的資料命為叫做firstString的字串

int firstNumber=Integer.parseInt(firstString);
//將firstString的資料改成integer的型態
System.out.println(firstNumber);
//將變成integer的資料print出來
System.exit(0);
//結束執行
}
}

0 Comments:

張貼留言

<< Home