In Java all the primitive types, except for char
, are signed. You can't have an unsigned byte.
The only thing you may do is to cast the unsigned byte to an int so you can read its proper value:
int a = b & 0xff
If you want to store an unsigned byte value in a byte type, you obviously can, but every time you need to "process" it, just remember to cast it again as showed above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…