Posts

Program 3 : Addition of 2 integer number which is given by the user using command line window.

Program :  Create a Java Program that make the Addition of 2 integer number which is given by the user using command line window. Solution : class SabTech { public static void main(String args[])     { if(args.length!=2) { System.out.println("Not enough arguments...Please Pass Exactly TWO arguments..."); System.exit(0); } int no1=Integer.parseInt(args[0]); int no2=Integer.parseInt(args[1]); int ans; ans=no1+no2; System.out.println("Addition of " + no1 + " and " + no2 + " is ==> " + ans); } } O/P: >javac SabTech.java >java SabTech 15 12 Addition of 15 and 12 is ==> 27

Program 2 : Getting Values from user on Command line Window.

Program :  Create a Java Program that Get Values from user on Command line Window. Solution : Here First we are displaying all the values which are entered by the user on command line window.               class SabTech               {                      public static void main(String args[])                      {                             int i;                             for(i=0;i<args.length;i++)                             {                                 ...

Program 1 : Create a Java Program that display "Hello World" on your command line window.

Program :  Create a Java Program that display "Hello World" on your command line window. Solution : Steps to create a Java Program:         1. Create new text file using notepad.         2. Now write given below code to your notepad file.               class SabTech               {                      public static void main(String args[])                      {                     System.out.println("Hello World");              }               }        3. Now save this file using "SabTech.java" . How to Compile and Run Java Program:        1.  Op...