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 System.in
Scanner input = new Scanner(System.in);
int i = sc.nextInt();    //execution will wait for input.
System.out.println(i);   //print input on console.

0 comments:

Post a Comment