## 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

3.Operators

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

1 2 3 4 5 6 7 8 9 10 | #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); } } |

**Output**

1 | 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