java - Where is the keyboard specified the System.in method? -


i can't conceptually understand in below code (that retrieves characters keyboards , prints command line) specified input must come keyboard?

public class adder {     public static void main(string arr[])     {          //explain next line, please:         scanner in = new scanner(system.in);             system.out.println("enter first no.");             int = in.nextint();             system.out.println("enter second no.");             int b = in.nextint();             int c = a+b;             system.out.println("sum is: "+c);         }     } 

system.in isn't method, it's field that's tied keyboard default.

the "standard" input stream. stream open , ready supply input data. typically stream corresponds keyboard input or input source specified host environment or user.

you can call system.setin(inputstream in) method change different input stream.

reference: i/o command line


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -