我在HashMap.java中看到了如下代码。
h ^= k.hashCode();
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded
// number of collisions (approximately 8 at default load factor).
h ^= (h >>> 20) ^ (h >>> 12);
return h ^ (h >>> 7) ^ (h >>> 4);
一些随机输入产生类似于加法的输出,但以下代码导致 0
int p = 10;
p ^= 10;
System.out.println("_______ " + p);
最佳答案
^=
运算符对左边的变量和操作数进行异或运算,然后将结果赋值给该变量。
与自身异或,结果为零。这是将寄存器设置为零的有效方法,因为它不会移动任何内存。
关于java - ^= 在 Java 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19339513/