package InputDemo;
public class InputDemo1 {
public static void main(String[] args) {
/*
1. java.util.Scanner 是一个扫描仪的类型,是引用数据类型,首字母大写,其中java.util是包
2. input 是一个变量名,它代表这个扫描仪
3. new java.util.Scanner(System.in)是input赋值的,它是一个新的对象
4. (System.in) 是指定了数据的来源是表示的输入设备,默认代表键盘输入
*/
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("请输入一个数字:");
int age = input.nextInt();
System.out.println("age:" + age); // 输入的和打印的换行
System.out.print("age:" + age); // 打印和输入的不换行
}
}
When nothing seems to help, I go look at a stonecutter hammering away at his rock, perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before. -- Jacob Riis