Java - Double doubleValue() Method
The java.lang.Double.doubleValue() method is used to return 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 below example, the java.lang.Double.doubleValue() method is used to return the given Double object as a double.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating Double objects Double val1 = new Double("25.2"); Double val2 = new Double("-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