By screener
via javarevisited.blogspot.com.au
Published: Feb 26 2013 / 08:36
Swapping two number without using temp variable is a classical programming exercise, appears in various Java Interviews. Couple of ways to solve it.
Comments
bloid replied ago:
Whilst reasonably interesting from an academic point of view, the addition and multiplication methods will fail if anything overflows. The multiplication method will fail if one of the variables is zero. Also all of the methods are harder to read and will probably be slower than using a temp variable and a decent compiler...
Voters For This Link (8)
Voters Against This Link (3)