Command-line Argument
Command-line argument is a method which user will give inputs through the console(command prompt) using commands.The argument accepted by main method is known as command line argument.
- The main method of java only access array of string as an argument.
- The argument passed from the console can be received in the JAVA program and it can be used as an input.
- Bide fault the length of command line argument in C or C++ is 1.
- In java the length of command line argument is 0.
- Length is a predefined variable which always return the size of the array in java.
PROGRAM
class Test
{
public static void main(String[] args)
{
System.out.println(Integer.parseInt(args[0]));
}
}
O/P:-depends upon input