Core Spring Data
Written by: Oliver Gierke
Featured Refcardz: Top Refcardz:
  1. Git
  2. Prep for CD
  3. DNS
  4. Data Mining
  5. Spring Data
  1. Data Mining
  2. Spring Data
  3. DNS
  4. Machine Learning
  5. MongoDB

Link Details

Link 930523 thumbnail
User 884233 avatar

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.
  • 8
  • 3
  • 849
  • 1152

Comments

Add your comment
User 111696 avatar

bloid replied ago:

-1 votes Vote down Vote up Reply

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...

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (8)



Voters Against This Link (3)