回覆列表
  • 1 # 碼農遊者

    java中Scanner類常用來進行資料的輸入。

    Scanner 類在java.util包中。

    操作例項:

    import java.util.Scanner;

    public class Main {

    public static void main(String args[]){

    Scanner sc = new Scanner(System.in);

    System.out.print("imput name:");

    String name = sc.nextLine();

    System.out.print("input age:");

    int age = sc.nextInt();

    System.out.print("input height:");

    float height = sc.nextFloat();

    System.out.print("name:" + name + "\n" + "age:" + age + "\n" + "height:" + height);

    }

    }

    輸出結果如下圖:

  • 中秋節和大豐收的關聯?
  • 0.5小時等於多少秒?