Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Long.doubleValue() method is used to return the value of this Long as a double after a widening primitive conversion.

Syntax

public double doubleValue()

Parameters

No parameter is required.

Return Value

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

Exception

NA.

Example:

In the below example, the java.lang.Long.doubleValue() method is used to return a Long object after conversion to type double.

import java.lang.*;

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

    //printing doubleValue of the Long objects
    System.out.println("doubleValue of the val1 is: " + val1.doubleValue()); 
    System.out.println("doubleValue of the val2 is: " + val2.doubleValue());   
  }
}

The output of the above code will be:

doubleValue of the val1 is: 25.0
doubleValue of the val2 is: -25.0

❮ Java.lang - Long