Java Program to Add Two Numbers

There are many way to add two numbers in Java. You can use add two numbers using bufferedreader, scanner, functions, methods and command line arguments. However, you can use the same program in IDE’s such as netbeans and Eclipse. The given below takes the user input to add two numbers. However it’s a simple program which uses Scanner method.

Here is the program :

import java.util.Scanner;
public class addition
public static void main(String args[])
Scanner sc = new Scanner (;
int a,b,c;
System.out.println(“Enter first number :”);
System.out.println(“Enter second number :”);
System.out.println(“The addition is :” +c);


The above program has been executed successfully. If you are unable to get the output that means you typed it wrong or did some mistake after copy pasting. 

Execute the program and enter the numbers to be added to get the addition of the numbers.

Add Comment