Odd Issue with ^= operator in Java

Правка en1, от Tomg, 2021-03-27 04:47:47

In Java, why is it that the code a^=b^=a^=b does not swap the values of a and b, while in C++, such code works? For example if a=1, and b=5, in Java, after doing a^=b^=a^=b, a=0, b=1.

Теги #java, #xor

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Tomg 2021-03-27 04:47:47 218 Initial revision (published)