+ 1

How can I make this working for swapping value in JAVA?

https://code.sololearn.com/cPezpVJ4Fb40/?ref=app

19th Aug 2020, 10:17 AM
AMAN
AMAN - avatar
3 ответов
+ 2
You did not declare a temporary variable to store num1 value or num2 and finally assign this value to num2 or num2 but in the middle set num1 = num2 ;
19th Aug 2020, 10:27 AM
HBhZ_C
HBhZ_C - avatar
+ 1
You did not declare a temporary variable to store num1 value or num2 and finally assign this value to num2 or num2 but in the middle set num1 = num2 ; I have to do it without declaration of a temporary variable i.e. in another way.
19th Aug 2020, 10:41 AM
AMAN
AMAN - avatar
+ 1
You can use bitwise xor operator here then. num1 = num^num2^(num1= num2)
19th Aug 2020, 10:47 AM
HBhZ_C
HBhZ_C - avatar