返回列表 發帖
  1. import java.util.Scanner;


  2. public class Test {

  3.         public static void main(String[] args) {
  4.                 Scanner s=new Scanner(System.in);
  5.                 String str1, str2;
  6.                 int a;
  7.                 float b;
  8.                 System.out.print("請輸入一字串(帶空白): ");
  9.                 str1= s.nextLine();
  10.                 System.out.println(str1);
  11.                 System.out.print("請輸入一字串(不帶空白): ");
  12.                 str2= s.next();
  13.                 System.out.println(str2);
  14.                 System.out.print("請輸入一整數: ");
  15.                 a= s.nextInt();
  16.                 System.out.println(a);
  17.                 System.out.print("請輸入一浮點數: ");
  18.                 b= s.nextFloat();
  19.                 System.out.println(b);
  20.         }

  21. }
複製代碼

TOP

返回列表