How to display a hex/byte value in Java
问题 int myInt = 144; byte myByte = /* Byte conversion of myInt */; Output should be myByte : 90 (hex value of 144). So, I did: byte myByte = (byte)myInt; I got output of myByte : ffffff90 . :( How can I get rid of those ffffff s? 回答1: byte is a signed type. Its values are in the range -128 to 127; 144 is not in this range. There is no unsigned byte type in Java. If you are using Java 8, the way to treat this as a value in the range 0 to 255 is to use Byte.toUnsignedInt : String output = String