L4, Synatx of main method, Introduction to main method, package q10792

The Java programs can be passed arguments on the command line while executing. These arguments are made available in a String array, which is passed into the main method.

How the arguments passed on command line are available to the main method.

See and retype the below code. The class CommandLineArgumentsDemo is passed 4 arguments during execution.

package q10792 :-

package q10792;
public class CommandLineArgumentsDemo {
    public static void main(String[] args) {
        System.out.println("args.length : " + args.length);
        System.out.println("args[0] : " + args[0]);
        System.out.println("args[1] : " + args[1]);
        System.out.println("args[2] : " + args[2]);
        System.out.println("args[3] : " + args[3]);

Post a Comment