A)
->during program execution values (literals) supplied from the commandline to the main method are known as commandline arguments.
->commandline arguments supplied are stored in the string array which is the parameter of JVM understandable main method.
Ex:
class commandlineexample {
public static void main(String[] args) {
System.out.println(args[0]);
for(inti=0;i<args.length;i++)
System.out.println(args[i]);
}
}
Note:
->to supply set of values at different times of java application execution without the need of changing the source code, commandline arguments are used.
->to supply set of values at different times of java application execution without the need of changing the source code, commandline arguments are used.
->different file names, url, user names and passwords are supplied from the commandline in general.
Comments
Post a Comment