Java source code examples

Java source code samples. Java code examples.

Convert a primitive byte value to a Byte object.

          0 votes

There are a couple of methods available in the Byte wrapper class that helps us to convert a primitive byte value to a Byte object.

public class BooleanWrapper {
	public static void main(String[] args) {
		byte b = 10;
		Byte objByte = new Byte(b);

		System.out.println(objByte);
	}
}

or

public class BooleanWrapper {
	public static void main(String[] args) {
		byte b = 10;
		Byte objByte = Byte.valueOf(b);

		System.out.println(objByte);
	}
}

Tags: java.lang

Discuss This Code