Java Program to Add Two Numbers Without Using Third Variable

Prem Tiwari - - 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

Prem Tiwari

Prem Tiwari is the founder of and also a professional developer and a blogger by hobby.

Tags: , , , ,

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.