Frage im Vorstellungsgespräch bei Sapiens

Java code to swap two numbers without using third variable.

Antwort im Vorstellungsgespräch

Anonym

18. Dez. 2019

int x = 10, y = 5; // Code to swap 'x' and 'y' x = x + y; // x now becomes 15 y = x - y; // y becomes 10 x = x - y; // x becomes 5