Java.lang.Number.doubleValue() 方法
描述
java.lang.Number.doubleValue() 方法将指定数字的值作为双精度值返回。 这可能涉及舍入或截断。
声明
以下是 java.lang.Number.doubleValue() 方法的声明。
public abstract double doubleValue()
参数
NA
返回值
该方法返回此对象转换为double类型后所表示的数值。
异常
NA
示例
下面的例子展示了 lang.Number.doubleValue() 方法的使用。
package com.tutorialspoint;
public class NumberDemo {
public static void main(String[] args) {
// get a number as integer
Integer x = new Integer(123456);
// get a number as float
Float y = new Float(9876f);
// print their value as double
System.out.println("x as integer :" + x
+ ", x as double:" + x.doubleValue());
System.out.println("y as float::" + y
+ ", y as double:" + y.doubleValue());
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
x as integer :123456, x as double:123456.0 y as float::9876.0, y as double:123456.0

