Site hosted by Angelfire.com: Build your free website today!
       
The Digital Reference Section

Example JAVA Program (Using Command Line Arguments
by Rodelio Barcenas

 /* This example program attemps to get the string
arguments at the command-line
the method .length refers to the the size of an array
the method .length() refers to the size of the string

*/

public class argument {

public static void main(String arg[]){

System.out.println("No. of Arguments: "+arg.length);
System.out.println(arg[0]);
System.out.println(arg[1]);
System.out.println(arg[2]);
System.out.println();

int a = arg[0].length();
int b = arg[1].length();
int c = arg[2].length();
System.out.println(arg[0]+"("+a+")");
System.out.println(arg[1]+"("+b+")");
System.out.println(arg[2]+"("+c+")");
}
}
Example usage : C:\>java argument the quick brown fox jump over


The PinoyTechZone.Com
Copyright 2002-2003
All rights Reserved