Java Command Line Argument
Chapter:
Java Basics
Last Updated:
27-12-2016 16:13:19 UTC
Program:
/* ............... START ............... */
public class JavaCommandLineArgs {
public static void main(String args[]) {
System.out.println("Argument is: " + args[0]);
}
}
/* ............... END ............... */
Output
compile : javac JavaCommandLineArgs.java
run : java JavaCommandLineArgs javascan
Output: Argument is : javascan
Notes:
-
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.
Tags
Command Line Argument, Java , Java Basics