With command line arguments it is possible to send configuration information to the application. 
Source: TestArgument.java
public class TestArgument {
         public static void main(String[] args) {        
            int size = Integer.valueOf(args[0]); 
            int[] list = new int[size]; 
System.out.println("Size of the array= " + list.length);
System.out.println("Size of the array= " + list.length);
}
     }
Output: Size of the array=25
Run:
java TestArgument  25
Syntax:
java  ProgramName  argument1  argument2  argumentN
 
No comments :
Post a Comment