Java Integer byteValue() method

The byteValue() is a method of byte class under java.lang package. It converts the given number into a primitive byte type and returns the value of integer object as byte. Also, it override the byteValue() method of Number class.

Syntax

Following is the declaration of byteValue() method:

Parameter:

DataTypeParameterDescription
byteNAIt returns the value of integer object as byte

Returns:

The byteValue() method returns the numeric value represented by this object after conversion to the primitive byte type.

Exceptions:

NA

Compatibility Version:

Java 1.5 and above

Example 1

Output:

Enter the Desired Numeric Value: 55
The Value of Byte is: 55

Example 2

Output:

34

Example 3

Output:

The Byte object is: 80
Primitive byte value of Byte object is: 80

Example 4

Output:

b = -1
i2 = 255