-1

I came across this line of code

for (int i = 1; i < nums.length; i++) num ^= nums[i]

What does ^= mean?

  • 2
    [Bitwise xor](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html) means the same thing outside a loop. `num = num ^ nums[i]`. See also [XOR gate](https://en.wikipedia.org/wiki/XOR_gate) Wikipedia entry. – Elliott Frisch Apr 02 '20 at 00:31

2 Answers2

0

It is the bitwise XOR operator. Check out this answer for a more in depth explanation.

0

It's a bitwise XOR operator normally used for """encryption""" it works like this:

A|B|Y
0|0|0
0|1|1
1|0|1
1|1|0

here is an example:

a ^ z
'a' in binary is 01100001 
'z' in binary is 01111010 
01100001 
01111010
00011011 = 27(ESC in ASCII)