Command Line Argument

/*Write a program for command line argument.*/
//programming789.blogspot.com
class CommandLineArgument
{
  public static void main (String args[])
  {
  try
  {
int a=Integer.parseInt(arr[0]);
int b=Integer.parseInt(arr[1]);
int sum=a+b;
System.out.println("result is =" +sum);
  }
  catch(Exception e)
  {
System.out.println(e); 
  }
  }
}

● Save the file as CommandLineArgument.java.


Output:-
>java CommandLineArgument 30 40
result is =70