Java 扫描仪输入 = new Scanner(System.in);
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24144859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scanner in = new Scanner(System.in);
提问by user3726654
public class Adder
{
public static void main(String arr[])
{
//System.in represents Standard Input Device (Keyboard)
//Explain this next line, please:
Scanner in = new Scanner(System.in);
System.out.println("Enter First No.");
int a = in.nextInt();
System.out.println("Enter Second No.");
int b = in.nextInt();
int c = a+b;
System.out.println("Sum is: "+c);
}
}
I just started learning JAVA and i came across this code.Can someone explain me what does the marked linesignify ?
我刚开始学习 JAVA,我遇到了这段代码。有人可以解释一下标记的线是什么意思吗?
回答by Balaji
Scanner s=new Scanner(System.in);
The System.in in the above code tells the compiler to get the data typed in the Keyboard, Which is a input device
上面代码中的 System.in 告诉编译器获取键盘输入的数据,这是一个输入设备
Thanks,
谢谢,
For more basic things in java Please checkout: Tutorialspoint.com
有关 Java 中的更多基本内容,请查看: Tutorialspoint.com