要将字节原始类型转换为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