Here you will get java program for addition of two numbers.
It is the very basic java program that is useful for beginners.
import java.util.Scanner; public class AddTwoNumbers { public static void main(String args[]){ int a, b, sum; Scanner sc = new Scanner(System.in); System.out.print("Enter first number: "); a = sc.nextInt(); System.out.print("Enter second number: "); b = sc.nextInt(); sum = a + b; System.out.print("\nSum = " + sum); } }
Output
Enter first number: 8
Enter second number: 4
Sum = 12