What is system.in

前端 未结 9 1080
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 05:50

Consider this Scanner input example.

Scanner user_input = new Scanner( System.in );

Here Scanner is the CLASS.

相关标签:
9条回答
  • 2021-02-06 06:37

    System.in is actually an InputStream typically connected to keyboard input of console programs.

    Along with it you have direct access also to two other streams System.out and System.err.

    System.in, System.out and System.err are initialized by the Java runtime when a Java VM starts.

    0 讨论(0)
  • 2021-02-06 06:37

    System.in in java means to take input from the keyboard or user. System.out in java means to print the output to console.

    0 讨论(0)
  • 2021-02-06 06:39

    System.in - "in" is object of class InputStream which is defined as static variables in class "System" which is used to read data from the console. In short "System.in" gives you a instance of of type InputStream.

    When we create a Scanner class object we need to pass "System.in" as parameter in Scanner class Constructor. So basically using "System.in" Scanner class becomes able to read the data from console and then using different methods which are provided by Scanner class (like nextInt(), nextLong(), next() etc.), we can get data in the form of our desired datatypes (like int, double, String etc.).

    0 讨论(0)
提交回复
热议问题