Java Program to Add Two Numbers Without Using Third Variable

By: Prem Tiwari | Last Updated: | In: Java Programming


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

Share this post!


About: Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.


Tags: , , , ,