Why swapping integer variable by XOR doesn't work in a single line?

后端 未结 5 2073
逝去的感伤
逝去的感伤 2020-12-16 17:59

I want to swap the value of two integer variables in java using the XOR operator.

This is my code:

int i = 24;
int j = 17;

i ^= j;
j ^= i;
i ^= j;

         


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