English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

在Java中将字节原始类型转换为Byte对象

要将字节原始类型转换为Byte对象,请使用Byte构造函数。

这是我们的字节原始类型。

byte b = 100;

现在让我们将其转换为Byte对象。

Byte res = new Byte(b);

让我们看完整的例子。

示例

public class Demo {
   public static void main(String[] args) {
      byte b = 100;
      Byte res = new Byte(b);
      System.out.println(res);
   }
}

输出结果

100