How to swap two numbers without using temporary variables in java

In this post, we will see how to swap two numbers without using temporary variables.
There are three ways to do it.
Java program:

When you run above program, you will get following output:

Third way is fastest of all.
Please go through Interview programs in java  for more such programs.

Add Comment