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
Post a Comment