Swap Two Numbers in Java

Swap Two Numbers in Java

In this program, you will get the code of Swap two numbers in java with the help of third variable.  Swapping with a third variable is a process of exchanging the values of two variables using with third temporary variable.

For example:-

int x = 5;
int y = 10;

int temp = x;
x = y;
y = temp;

Program:

Output:

SwapTwoNumbers

Leave a Comment

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

Scroll to Top