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 - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -