Following simple code shows how to pass command line arguments to to Java program:
1 public class CommandLineInput {
2 public static void main (String[] args) {
3 for (String argument: args) {
4 System.out.println(argument);
5 }
6 }
7 }
Running the program
javac CommandLineInput.java java CommandLine 30000 students
Output of this program
30000 students
Explanation
All command line arguments are passed to a String array named args defined on line 2 of the code. Since all arguments are stored in an array in the order they were passed, you simply need to access the array to get the command line parameters and cast them to another type in necessary.