...
This compliant solution masks off the upper 24 bits of the promoted byte array element. The result is then combined with result using a logical OR operation.
| Code Block | ||
|---|---|---|
| ||
byte[] b = new byte[] {-1, -1, -1, -1};
int result = 0;
for (int i = 0; i < 4; i++) {
result = ((result << 8) | (b[i] & 0xff));
}
|
...