J
JOptionPane.showMessageDialog( null, "Hello World" ); // static method, 跳出對話視窗
JOptionPane.showInputDialog( "What is your name?" ); // static method, 跳出輸入視窗, 回傳輸入字串
S
Scanner
|| import java.util.Scanner;
|| Sacnner input= new Scanner(System.in); //input是抓鍵盤輸入的值
|| int number1 = input.nextInt() //nextInt(): 取得下一個input的Integer
|| String name = input.nextLine(); //nextLine(): 取得下一個input的字串
String.format( "%s, %d", name, number ); // static method, 回傳一個經過format的字串
System.out.printf( "%s\n%s\n", "Welcome to", "Java Programming!" ); // static method 印出字, 數字等等
System.out.println( "Hello World!" ); // static method 印出一行字"Hello World!"
No comments:
Post a Comment