Add two numbers in Java

Add two numbers in Java 

 
Step 1: Let's open a notepad and write the following code.
 
//Code
  1. class demo {  
  2.  public static void main(String arg[]) {  
  3.   int a = 10, b = 20, c = 0;  
  4.   c = a + b;  
  5.   System.out.println("sum of two no is :" + c);  
  6.  }  
  7. }   
Step 2: Name it as "ab.java" and save the file on any location. I saved at "C:\app".
 
Step 3: Open command prompt (Press Window + R and write cmd and hit OK).
 
a
 
Step 4: Go to "C:\app" by using command prompt
 
s
 
Step 5: Now write the following code for checking my java file is compiling or not.
 
javac ab.java
 
d
 
My java program compiled successfully.
 
Step 6: Write the following code in command prompt. Press enter and see the output.
 
java demo
 
// demo is a class name that is written in my ab.java file.
 
Output
 
f
 
Happy Coding.