- import java.util.Scanner;
- public class Ch43
- {
- public static void main(String arg[])
- {
- Scanner s=new Scanner(System.in);
- String str1, str2;
- int a;
- float b;
- System.out.print("請輸入一字串(帶空白): ");
- str1 = s.nextLine();
- System.out.println(str1);
- System.out.print("請輸入一字串(不帶空白): ");
- str2 = s.next();
- System.out.println(str2);
- System.out.print("請輸入一整數: ");
- a = s.nextInt();
- System.out.println(a);
- System.out.print("請輸入一浮點數: ");
- b = s.nextFloat();;
- System.out.println(b);
- }
- }
複製代碼 |