i

JAVA Complete Course

Command Line Arguments

The java command-line argument is an argument i.e. passed at the time of running the java program. The arguments passed from the console can be received in the java program and it can be used as an input. So, it provides a convenient way to check the behavior of the program for the different values. You can pass N (1,2,3 and so on) numbers of arguments from the command prompt.

Let’s see the simple example of passing command line argument to Java program:

To run this we need the following commands:

As we have already mentioned, we can pass as many command line arguments to our programs as we want. Let’s see the example of passing multiple command line arguments and print all of them: