//key & hash are both byte[]
int leftPos = 0, rightPos = 31;
while(leftPos < 16) {
//possible loss of precision. required: byte, found: int
key[leftPos] = hash[leftPos] ^ hash[rightPos];
leftPos++;
rightPos--;
}
Run Code Online (Sandbox Code Playgroud)
为什么Java中的两个字节的按位运算会返回一个int?我知道我可以把它转回到字节,但它看起来很傻.
我想知道为什么在计算表达式或按位运算时将byte和short提升为值的原因int?