Determine how many arguments were passed using length property
In java, array knows their size by using the length property. By using, length property we can determine how many arguments were passed. The following code example can accept any number of arguments
/* This Java application illustrates the use of Java
command-line argument s. */
public class AnyArgsApp {
public static void main(String[] args){ //main method
for(int i=0; i < args.length; i++)
System.out.println ("Argument :" + i + "value" +args[i]) ;
}//end main
}//End class.
Output
C:\java AnyArgsApp i can pass any number of arguments
Argument:0 value i Argument:1 value can
Argument:2 value pass Argument:3 value
any Argument:4 value number Argument:5
value of Argument:6 value arguments