You are on page 1of 2

// 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

You might also like