集册 Java实例教程 通过扫描仪类获取输入

通过扫描仪类获取输入

欢马劈雪     最近更新时间:2020-01-02 10:19:05

394
通过扫描仪类获取输入

import java.util.Scanner;


public class ScannerApp
/*
NowJava.com
*/

{

  static Scanner sc = new Scanner(System.in);


  public static void main(String[] args){

    System.out.print("Enter an integer: ");

    int x = sc.nextInt();

    System.out.println("You entered " + x + ".");

  }

}