The compiler seems to be ok with this (single digit hex values only):
byte[] rawbytes={0xa, 0x2, 0xf};
But not this:
byte[]
byte is signed and 0xff = 255 is too big. The valid range is (-128 .. 127).
byte
0xff = 255
Example code:
public static void main(String[] args) { byte b = (byte) 0xff; // = -1 int i = b; // = -1 int j = b & 0xff; // = 255 System.out.printf("b=%s, i=%s, j=%s", b,i,j); }