Why is “a^=b^=a^=b;” different from “a^=b; b^=a; a^=b;”?

前端 未结 6 1063
梦如初夏
梦如初夏 2020-12-05 14:53

I tried some code to swap two integers in Java without using a 3rd variable, using XOR.

Here are the two swap functions I tried:

package lang.numeric         


        
6条回答
提交回复
热议问题