How to read input from command line in Java?

The Scanner class was implemented in Java 5.0 to make getting input easier.
To read input from standard input that is console input we use scanner with
Scanner input = new Scanner(;
int i = sc.nextInt();    //execution will wait for input.
System.out.println(i);   //print input on console.


Post a Comment