Byte toUnsignedInt(byte x)
converts a byte to unsigned int.
Zero and positive byte values converts to a numerically equal int value.
Negative byte values converts an int equal to the input + 256.
toUnsignedInt
has the following syntax.
public static int toUnsignedInt(byte x)
toUnsignedInt
has the following parameters.
toUnsignedInt
returns
the byte converted to int by an unsigned conversion
The following example shows how to use toUnsignedInt
.
/*w w w. j a va2s . c o m*/ public class Main { public static void main(String...args){ byte b = 2; System.out.println(Byte.toUnsignedInt(b)); b = -2; System.out.println(Byte.toUnsignedInt(b)); } }
The code above generates the following result.