Swapping two variables in Java without using a third variable or an API -


this question has answer here:

i went interview , asked write code swap values of 2 variables without using third variable or api.

i not work out how this, can me on this?

for example have 2 variable a=10 , b=20 output should b=10 , a=20.

tricky not hard figure out:

a = 10 b = 20  = + b; //a = 30, b = 20 b = - b; //a = 30, b = 10  = - b; //a = 20, b = 10 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -