Java Code:
1 2 3 4 5 6 7 8 9 |
public class Main { public static void main(String args[]) { System.out.println("Argument is: " + args[0]); } } |
Output:
1 2 3 |
Output: Argument is : helloWorld |
The java command-line argument is an argument that is 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.
A Java application can accept any number of arguments from the command line. This allows the user to specify configuration information when the application is launched.