Swap Two Numbers in Java

Here you will get the program 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 to Swap two numbers in Java

Output

SwapTwoNumbers

 

 

Check out our other Java Programming Examples

 

 

 

Leave a Comment

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

Scroll to Top