更新时间:2023-01-11 20:34:23
最简单的方法之一是使用扫描仪
对象如下:
One of the simplest ways is to use a Scanner
object as follows:
import java.util.Scanner;
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter a number: ");
int n = reader.nextInt(); // Scans the next token of the input as an int.
//once finished
reader.close();