Consider this Scanner
input example.
Scanner user_input = new Scanner( System.in );
Here Scanner
is the CLASS.
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.
System.in
in java means to take input from the keyboard or user.
System.out
in java means to print the output to console.
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.).