Scanner in =新的Scanner(System.in); [英] Scanner in = new Scanner(System.in);

查看:50
本文介绍了Scanner in =新的Scanner(System.in);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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);    
    }    
}

我刚开始学习JAVA,遇到了这段代码.有人可以解释一下标记行表示什么吗?

I just started learning JAVA and i came across this code.Can someone explain me what does the marked line signify ?

推荐答案

Scanner s=new Scanner(System.in);

以上代码中的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

谢谢

有关Java中的更多基本知识,请检出: Tutorialspoint.com

For more basic things in java Please checkout: Tutorialspoint.com

这篇关于Scanner in =新的Scanner(System.in);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆