I have a question about initializing byte in java, I want to initialize a byte value allBitsOne and all bits of it are 1:
Method 1:
byte allBitsOne = 0xFF;
Wrong, it says that 0xFF is a integer type and over the range of byte, so i do it like below
Method 2:
byte allBitsOne = (byte)0xFF;
Works fine.
Method 3:
byte allBitsOne = 0xFFFFFFFF;
It works fine as well, but if 0xFF
exceeds the range of a byte, why doesn't 0xFFFFFFFF
?
Thank you all, I found this: link