1. Home
  2. Java
  3. Java Examples
  4. Add Two Numbers

Add Two Numbers

Java – Calculate Sum of Two Numbers

Write A Java Program to calculate the sum of two numbers. In the first program, we have predefined values for two integer variables and calculate the sum of them.

Compile and run this program:

javac AddNumbers.java
java AddNumbers

Output:

Sum is: 45