0
Hello everybody! How would you swap the value of two variables without use any other variable in Java?
For example a=10 and b=5. The result should be a=5 and b=10
3 ответов
0
Sorry, I was not trying to test you. It's just that I saw the question in a challenge here in SoloLearn and I want to know the right answer.
Anyway, here is the way to do it:
a = a + b;
b = a - b;
a = a - b;