Java.lang Package Classes

Java Byte - longValue() Method

The java.lang.Byte.longValue() method returns the value of this Byte as a long after a widening primitive conversion.


public long longValue()


No parameter is required.

Return Value

Returns the numeric value represented by this object after conversion to type long.




In the example below, the java.lang.Byte.longValue() method returns a Byte object after conversion to type long.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    //creating Byte objects
    Byte val1 = 25;
    Byte val2 = -25;

    //printing longValue of the Byte objects
    System.out.println("longValue of the val1 is: " + val1.longValue()); 
    System.out.println("longValue of the val2 is: " + val2.longValue());   

The output of the above code will be:

longValue of the val1 is: 25
longValue of the val2 is: -25

❮ Java.lang - Byte