Java Program to Add Two Numbers

September 18, 2017

Are you searching for the Java program to add two numbers? Here is the program to add two numbers in Java.

Java Program to Add Two Numbers

In this java program, we are using two variables to store two numbers. And values are stored in the variables using the scanner method.

/* Java Program to Add two numbers*/
import java.util.Scanner;

public class JavaProgram
 public static void main(String args[])
 int x, y, sum;
 Scanner scan = new Scanner(;
 System.out.print("Enter the Two Numbers : ");
 x = scan.nextInt();
 y = scan.nextInt();
 sum = a + b;
 System.out.print("Sum of these two numbers: " +sum);

If you have any doubts about this Java program to add two numbers, comment below.

Tagged in:
About Author
Adeeb C (219 Articles)

Adeeb C is the founder of this website. He is a blogger and web developer. And he writes about latest technology news, gadgets and windows since last four years.