What does value & 0xff do in Java?

It sets result to the (unsigned) value resulting from putting the 8 bits of value in the lowest 8 bits of result. The reason something like this is necessary is that byte is a signed type in Java. If you just wrote: then result would end up with the value ff ff ff fe instead of 00 00 00 fe. A further subtlety is that the & is defined … Read more