<分区>
大家好,我有一个带 ~ 运算符的 for 循环 以前从未在任何代码上发现过这个
for (int i = 0; i < bytes.length; i++) {
mashed[i] = (byte) ~bytes[i];
}
~是做什么的?
我还没有在互联网上或之前的任何地方找到过这样的东西 所以也许有人可以帮我提前谢谢
<分区>
大家好,我有一个带 ~ 运算符的 for 循环 以前从未在任何代码上发现过这个
for (int i = 0; i < bytes.length; i++) {
mashed[i] = (byte) ~bytes[i];
}
~是做什么的?
我还没有在互联网上或之前的任何地方找到过这样的东西 所以也许有人可以帮我提前谢谢
最佳答案
它是的运算符~按位非
The bitwise NOT "~" operator inverts each bit in the operand i.e. this operator changes all the ones to zeros and all the zeros to ones.
并了解内部工作原理:How does the bitwise complement (~) operator work?
关于java - 什么是 ~ 运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17381624/