Command line arguments
Java command-line argument is an argument, i.e., passed at the time of running the Java program. In Java,
the command line arguments passed from the console can be received in the Java program, and they can be
used as input. The users can pass the arguments during the execution, bypassing the command-line arguments
inside the main() method.
When we run a Java program, we can give extra information right after the program name. This extra
information is called command-line arguments. Let's understand this with the help of an example. If we run
this,
Java classname helo view
Here the words helo and view are command line arguments. The jvm collect these words and pass this words
to main method as the array of string called args. The jvm passes this to the program inside args[0] and args[1]
Why Use Command Line Arguments?
It is used because it allows us to provide input at runtime without modifying the whole program.
It helps to run programs automatically by giving them the needed information from outside.