Java.lang Package Classes

Java Float - doubleValue() Method



The java.lang.Float.doubleValue() method returns the value of this Float as a double after a widening primitive conversion.

Syntax

public double doubleValue()

Parameters

No parameter is required.

Return Value

Returns the float value represented by this object converted to type double.

Exception

NA.

Example:

In the example below, the java.lang.Float.doubleValue() method returns a Float object after conversion to type double.

import java.lang.*;

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

    //printing doubleValue of the Float 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 - Float