Sunday, January 1, 2012

Addition of 2 no by command line argument in Java

Example



import java.io.*;
public class A12
{
public static void main(String args[])
{

try
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println(" Addition of two number:"+(a+b));
}

catch(Exception e)
{
System.out.println("Enter number to add");
}

}
}

No comments:

Post a Comment