Problem : Write a program that adds two arguments that passed through command line arguments?
Program :Step 1 - CodingCreate a text file c:\sunilos\Add.java and copy below contents./* * A program which take two integer from command line argument and add. */ public class Add { public static void main(String[] args) { int a = Integer.parseInt(args[0]); //Integer.parseInt method converts String data type into Integer int b = Integer.parseInt(args[1]); int sum = a + b; System.out.println("Sum is " + sum); } } Step 2 - Deployment
Step 3 - Testing
OutputIt will display result Sum is 14 <<Previous | Next>> |