In this example, you created a program to add two integer numbers in Java. After addition, the final sum is displayed on the screen.
Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | package javaexamples; public class JavaExamples { public static void main(String[] args) { int first = 200; int second = 120; int sum = first + second; String output = String.format("%d + %d = %d",first,second,sum); System.out.println(output); } } |
Output: