Showing posts with label Swap Two Numbers. Show all posts
Showing posts with label Swap Two Numbers. Show all posts

Java Program to swap values of two numbers without temporary variable

  • 0
A typical value swapping progran involves use of a temporay storage to store the value of either of the two variables whose values is to be swapped. In here, I would try to make you understand the true logic of the oprogrm. This program is simply based on the fact that java assignment statement, for example,
a = 1 +3;
would add first 1 and 3, after the addition, the value is stored in the left hand value of the storage variable. Now, the program swapping vales is.