Command Line Argument In Java

Command line arguments are the arguments which are passed when you are running the java program as seen in the output below.

class Add
{
public static void main(String args[])
{
int sum=0;
for(int i=0;i< args.length ;i++)
{
sum=sum+Integer.parseInt(args[i]);
}
System.out.println(" "+sum);
}
}

Leave a Reply