首页javabyteJava Data Type - 如何将值存储在一个字节中作为无符号整数

Java Data Type - 如何将值存储在一个字节中作为无符号整数

我们想知道如何将值存储在一个字节中作为无符号整数。
public class Main {
  public static void main(String[] args) {
    byte b = -10;
    int x = Byte.toUnsignedInt(b);
    System.out.println("Signed value in byte   = " + b);
    System.out.println("Unsigned value in  byte   = " + x);

  }
}