I need an unsigned 8 bit integer in Java, and char seems to be the only thing close to that. Although it's double the size, it's unsigned which makes it practical for what I want to use it for (writing a basic emulator which requires unsigned bytes). The problem is that I've heard other programmers say that one shouldn't use char in that manner and should just use int or so. Is this true, and why so?
解决方案
If you need an unsigned 8 bit integer then use byte. It's easy to make it unsigned in arithemtic operations (where actually sign matters) as byteValue & 0xFF