返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch02
  3. {
  4.    public static void main(String args[])
  5.    {
  6.        Scanner s=new Scanner(System.in);
  7.        String str1, str2;
  8.        int a;
  9.        float b;
  10.        System.out.print("請輸入一字串(帶空白): ");
  11.        str1=s.nextLine();
  12.        System.out.println(str1);
  13.        System.out.print("請輸入一字串(不帶空白): ");
  14.        str2=s.next();
  15.        System.out.println(str2);
  16.        System.out.print("請輸入一整數: ");
  17.        a=s.nextInt();
  18.        System.out.print(a);
  19.        System.out.println("請輸入一浮點數: ");
  20.        b=s.nextFloat();
  21.        System.out.println(b);
  22.    }
  23. }
複製代碼

TOP

返回列表