0542-2316689 | [email protected]

Java Program to Add Two Numbers

Java Program to Add Two Numbers-Initializing Method

To properly understand a Java Program to Add Two Numbers, you should have the knowledge of following Java programming topics:


1.Input, Output, and Import
2.Variables and Data Types

In the following program, we have used the arithmetic addition operator i.e (+) to adds two numbers.

#Java Program to Add two numbers
class Add2nos{
        public static void main(String args []){

                double num1 = 2.5, num2 = 4.3, sum;
                sum = num1 + num2;

                System.out.println("Sum of "+num1 +" and " +num2 +"is: "+sum);


Sum of 2.5 and 4.3 is: 6.8


Most Importantly as mentioned above Java uses all the mathematics operation therefore by Changing (+) operator, we can subtract (-), multiply (*), divide (/), floor divide (//) or find the remainder (%) of two numbers.

Related Program

1.Java Program to find the area of Triangle
2.Java Program to Solve Quadratic Equation
3.Java Program to Generate a Random Number

Ask your questions and clarify your/others doubts by commenting. Java Documentation

0 responses on "Java Program to Add Two Numbers"

Leave a Message

Your email address will not be published. Required fields are marked *

© 2017-18 TCA