Suppose you are doing your coding in java (let you are running your program from command prompt of your desktop) and you need to take input from user in command line or command prompt while user run (actually runtime input) your program.
Now I will show you how to take user input from command prompt or command line in java.
Here I have used BufferedReader and readLine() to take input from user in command line/ command prompt while the program was running or simply in run time.
In the example below br.readLine() takes input as String, in the next line we have parsed or convert that String into integer.
public class CmdLineInput
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter the number of Students:”);
System.out.println(“Number of Students:”+num_std);
public static void main(String args)
CmdLineInput takeinput=new CmdLineInput();