接收数据 | 方法 |
---|---|
int | nextInt() |
long | nextLong() |
float | nextFloat() |
double | nextDouble() |
字符串类型 | next() |
布尔类型 | nextBoolean() |
案例如下:
Scanner sc = new Scanner(System.in);
// 1.从键盘接收int类型数据
int n = sc.nextInt
接收数据 | 方法 |
---|---|
int | nextInt() |
long | nextLong() |
float | nextFloat() |
double | nextDouble() |
字符串类型 | next() |
布尔类型 | nextBoolean() |
案例如下:
Scanner sc = new Scanner(System.in);
// 1.从键盘接收int类型数据
int n = sc.nextInt