Java.lang Package Classes

Java Double - doubleValue() Method



The java.lang.Double.doubleValue() method returns the double value of this Double object.

Syntax

public double doubleValue()

Parameters

No parameter is required.

Return Value

Returns the double value represented by this object.

Exception

NA.

Example:

In the example below, the java.lang.Double.doubleValue() method returns the given Double object as a double.

import java.lang.*;

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

    //printing doubleValue of the Double 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.2
doubleValue of the val2 is: -25.2

❮ Java.lang - Double

5