本帖最後由 tonyh 於 2013-5-27 20:16 編輯
- import java.util.Scanner;
- public class ch12 //類別
- {
- public static void main(String args[]) //主方法
- {
- Scanner s=new Scanner(System.in);
- String a;
- int b;
- float c;
- System.out.print("請輸入一字串: ");
- a=s.next(); //a=s.nextLine()
- System.out.println(a);
- System.out.print("請輸入一整數: ");
- b=s.nextInt();
- System.out.println(b);
- System.out.print("請輸入一浮點數: ");
- c=s.nextFloat();
- System.out.println(c);
- }
- }
複製代碼 |