Write a Java Program to Add Two Integers

Write a Java Program to Add Two Integers

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class Main {

  public static void main(String[] args) {
    
    int first = 10;
    int second = 20;

    // add two numbers
    int sum = first + second;
    System.out.println(first + " + " + second + " = "  + sum);
  }
}

 

Final Output

1 thought on “Write a Java Program to Add Two Integers”

Leave a Comment