java.lang.Long byteValue()


The byteValue() java method returns the value of this Long as a byte after a narrowing primitive conversion.



  • This method overrides byteValue in class Number

Method Syntax

public byte byteValue()

Method Argument

Data Type Parameter Description

Method Returns

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


Requires Java 1.0 and up

Java Long byteValue() Example

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


 * This example source code demonstrates the use of  
 * byteValue() method of Long class

public class LongByteValueExample {

	public static void main(String[] args) {

		// Declare a new Long variable
		Long value = 123l;

		// get the byteValue() method result
		byte result = value.byteValue();

		// print the result
		System.out.println("Result:" + result);
		 * Be careful on using this method
		 * Desired result might differ
		 * because of the narrowing concept
		 * of java language



Sample Output

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

java Long byteValue() example output