Java Basic Examples

Convert Byte object to numeric primitive types Example

This example shows how to convert Byte object to numeric primitive types like Byte object to byte, Byte object to short, Byte object to int, Byte object to long, Byte object to float and Byte object to double.

How to convert Byte object to numeric primitive types in Java?

Use xxxValue method of Byte wrapper class to convert Byte object to primitive numeric types where xxx is the primitive type you want to convert to as given below.

1) Convert Byte to byte

Use byteValue method of Byte wrapper class to convert from Byte to byte primitive value.

This method returns the value of the Byte object as byte primitive.

2) Convert Byte to short

Use shortValue method of Byte wrapper class to convert from Byte to short primitive value.

This method returns the value of the Byte object as short primitive.

3) Convert Byte to int

Use intValue method of Byte wrapper class to convert from Byte to int primitive value.

This method returns the value of the Byte object as int primitive.

4) Convert Byte to long

Use longValue method of Byte wrapper class to convert from Byte to long primitive value.

This method returns the value of the Byte object as long primitive.

5) Convert Byte to float

Use floatValue method of Byte wrapper class to convert from Byte to float primitive value.

This method returns the value of the Byte object as float primitive.

6) Convert Byte to double

Use doubleValue method of Byte wrapper class to convert from Byte to double primitive value.

This method returns the value of the Byte object as double primitive.

Example

Output

Please let us know your views in the comments section below.

Join 1000+ fellow learners! Enter your email address below: