Java Program to Swap Two Numbers

In this program, you'll learn two techniques to swap two numbers in Java. The first one uses a temporary variable for swapping, while the second one doesn't use any temporary variables.

When you run the program, the output will be:

Before Swap
First number = 12.0
Second number = 24.5
After Swap
First number = 24.5
Second number = 12.0

Post a Comment

Thank you for vising

Previous Post Next Post