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

Convert byte primitive type to Byte object in Java

To convert the byte primitive type to a Byte object, please use the Byte constructor.

This is our original byte type.

byte b = 100;

Now let's convert it to a Byte object.

Byte res = new Byte(b);

Let's see the complete example.

Example

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

Output Result

100