How to pass argument in main function of java program using command line argument
How to pass argument in main function of java program using command line argument There are only one way to pass argument in main() function of java program and that is using command line .Here is the step by step procedure of how to pass argument using command line. As main function have a formal parameter i.e., args[] which is array of String type and accepts number of arguments passed during the run time of program through command line. This is illustration of program to calculate the sum of number passed by user as argument in main function. public class CommandLine { public static void main(String []args) { int sum=o; for(int i=0;i<args.length;i++) {sum=sum+Integer.parseInt(args[i]); /* Here the argument accepted from command line are added one by one.But there is problem as command line arguments are of String type ,Hence we need to convert them before adding wh...