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

TOP

返回列表