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 (223 Articles)

Adeeb C is a Web Designer, Web Application Developer, Android App Developer, WordPress Developer, Professional Blogger. He has 5 years of experience in WordPress, Web Developing, Professional Blogging, and 2 years of experience in Android App Developing.