Java Number - doubleValue() Method
The java.lang.Number.doubleValue() method returns the value of the specified number as a double, which may involve rounding.
Syntax
public abstract 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 example below, the java.lang.Number.doubleValue() method returns the double value of the given numbers.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating an Integer value Integer val1 = 123; //creating a Float value Float val2 = 55.75f; //printing the double value of given numbers System.out.println("double value of val1: " + val1.doubleValue()); System.out.println("double value of val2: " + val2.doubleValue()); } }
The output of the above code will be:
double value of val1: 123.0 double value of val2: 55.75
❮ Java.lang - Number