Byte.toUnsignedInt(): This method is available in the java.lang.Byte class of Java.
Syntax:
int java.lang.Byte.toUnsignedInt(byte x)
This method takes one argument of type byte as its parameter. This method converts the argument to an int by an unsigned conversion. In an unsigned conversion to an int, the high-order 24 bits of the int are zero and the low-order 8 bits are equal to the bits of the byte argument.
Parameters: One parameter is required for this method.
x: the value to convert to an unsigned int.
Returns: the argument converted to int by an unsigned conversion.
For Example:
Byte.toUnsignedInt(123) = > It returns 123.
Approach
Java
public class BytetoUnsignedInt {public static void main(String[] args) {byte x = 123;System.out.println(Byte.toUnsignedInt(x));}}
Output:
123
No comments:
Post a Comment