Q) develop a java program that display the sum of two numbers supply the 2 numbers from the commandline?
A)
class add {
public static void main(String[] args) {
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println("the sum :"+(a+b));
}
}
Note:
here ‘parseInt’ is a method. It belongs to the ‘Integer’ class. It is declared as static, that’s why it is called by using class name.
here ‘parseInt’ is a method. It belongs to the ‘Integer’ class. It is declared as static, that’s why it is called by using class name.
Comments
Post a Comment