java.lang.Byte byteValue()


The byteValue() method of Byte class Returns the value of this Byte as a primitive byte.

Important Notes:

  • The method  byteValue() overrides byteValue in class Number

Method Syntax

public byte byteValue()

Method Argument

Data Type Parameter Description

Method Returns

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


Requires Java 1.1 and up

Java Byte byteValue() Example

Below is a simple java example on the usage of byteValue() method of Byte class.

Basically on the above example, we have declared a new Byte object and then eventually converted into primitive byte. As you would have noticed already, the printed value is the same as the instantiated Byte object. But remember that the result is now a primitive type. Anyway because of autoxing and unboxing features which have been introduced at the newer version of java, the byteValue() method renders as obsolete.

Sample Output

Below is the sample output when you run the above example.

java Byte byteValue() example output