Java Integer doubleValue() method
The doubleValue() method of Integer class returns a double value for this Integer after a widening primitive conversion.
Syntax
public double doubleValue()
Parameters
NA
Specified by
This method is specified by doubleValue in class Number
Return Value
This method returns the numeric value of this object after conversion to type double.
Example 1
public class JavaIntegerDoubleValueExample1 { public static void main(String[] args) { Integer val1=23; //returns a double value for this Integer double d1= val1.doubleValue(); System.out.println(d1); Integer val2=45; System.out.println(val2.doubleValue()); } }
Output
23.0 45.0
Example 2
public class JavaIntegerDoubleValueExample2 { public static void main(String[] args) { Integer val1=23; //returns a double value for this Integer double d1= val1.doubleValue(); Integer val2=45; double d2=val2.doubleValue(); //calling the double class methods System.out.print(d1+"+"+d2+" : "); System.out.println(Double.sum(d1,d2)); } }
Output
23.0 + 45.0 : 68.0
Example 3
public class JavaIntegerDoubleValueExample3 { public static void main(String[] args) { Integer val1=23; //returns a double value for this Integer double d1= val1.doubleValue(); Integer val2=45; double d2=val2.doubleValue(); //calling the double class methods System.out.print("Greatest number between "+d1+" and "+d2+" : "); System.out.println(Double.max(d1,d2)); } }
Output
Greatest number between 23.0 and 45.0 : 45.0