26.how To Read Input From Command Line in Java Using Scanner
26.how To Read Input From Command Line in Java Using Scanner
Vishnu
Scanner class is used to read input from command line. Scanner class is in java.util
package. Scanner class has methods like nextInt(), nextFloat(), nextDouble() etc which
read numeric data without any need of parsing using Integer.parseInt() etc. These
methods will throw an exception if you pass string or char type value.
Example:
Package com.sst;
import java.io.InputStreamReader;
import java.util.Scanner;
Output:
1
Sri Sureka Technologies, NearAndraBank,OppositeGeethanjali High School, Near
S.R.NagarUmeshChandraStachu, S.R.Nagar, Hyderabad-500038, Ph: 040-66616677, Mobile: +91-
9885602332.
26.How to read input from command line By Mr. Vishnu
2
Sri Sureka Technologies, NearAndraBank,OppositeGeethanjali High School, Near
S.R.NagarUmeshChandraStachu, S.R.Nagar, Hyderabad-500038, Ph: 040-66616677, Mobile: +91-
9885602332.