How to write a Java Program to Swap Number Without Temporary Variable

Prem Tiwari - - Java Programming


In one of the previous tutorial, I have explained how to swap two numbers in java programming language. In this tutorial, I will share how to write a java program to swap number without a temporary variable.

How to write a Java Program to Swap Number Without Temporary Variable

Copy the below java program and execute it with the help Java compiler. At the end of this tutorial, I have shared the output of the following programs.

Program Output

Enter the number x and y:
30
10
Before Swapping:
30
10
After Swapping:
10
30


Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com 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.