Command Line Arguments in java with example.
Command Line Arguments:
Sometimes you will want to pass information into a program when you run it. This is accomplished by passing command-line arguments to main( ). A command-line argument is the information that directly follows the program’s name on the command line when it is executed. To access the command-line arguments inside a Java program is quite easy—they are stored as strings in the String array passed to main( ).
Example:
// Display all command-line arguments.
class CommandLine
{
public static void main(String args[])
{
for(int m=0; mi<args.length; m++)
System.out.println("args[" + m + "]: " + args[m]);
}
}
Post a Comment
Post a Comment
Please do not enter any spam link in the comment box