You are here: Home / Topics / Simple Sum Program Using Windows Command in Java

Simple Sum Program Using Windows Command in Java

Filed under: Java on 2023-08-11 19:19:25

// Simple sum example using command line

class  Sum
{
public static void main( String args[ ] )
{
 int  num1, num2, sum;

 num1 = Integer.parseInt( args[0] );
 num2 = Integer.parseInt( args[1] );

 sum = num1 + num2;

 System.out.println( " Sum = " + sum );
}
}

Output: (In command Prompt)

D:\Java Examples>javac sum.java

D:\Java Examples>java sum 150 250

Sum = 400

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.