Java Command Line Arguments

Command line arguments are parameters that are supplied to the application program at the time of invoking it for execution. The arguments which are passed onto main() are Command line arguments.

Use of Command Line Arguments in Java

class  command

{

public static void main(String aa[])

{

int cc, ii=0;

String stri;

cc=aa.length;

System.out.println(“Number of Arguments=”+cc);

while(ii<cc)

{

stri=aa[ii];

ii=ii+1;

System.out.println(ii+”:”+”Java is”+stri+”!”);

}

}

}

Java Command Line arguments

Explanation.

Here, aa is declared as an array of strings (known as string objects). Any arguments provided in the command line(at the time of execution)are passed to the array aa as its elements. To run this program…

Javac command.java

Java command basic, java

This command line contains four arguments. These are assigned to the array aa as follows…

Basic……..aa[0]

Java……..aa[1]