Java Program to Add Two Numbers Without Using Third Variable

In this tutorial, I will explain how to write a Java program to add two numbers without using the third variable.
In this program, I have declared two variables as X and Y with some values, after that, used plus operator to save both values and put the result in the first variable.

Java program to add two numbers without using third variable

Copy the below Java program and execute it with the help of Java compiler to see the output of below program.

At the end of this tutorial, I have shared the real-time output.

Program Output

Sum of two numbers: 25

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:

Article Tags: , , , ,