Java Double Value()方法及示例
Double类的 doubleValue() 方法是一个内置的方法,用于将调用对象指定的值在类型转换后返回为double。
语法:
DoubleObject.doubleValue()
返回值: 它返回DoubleObject的值为 Double 以下程序说明了Java中的doubleValue()方法:
程序1 :
// Java code to demonstrate// Double doubleValue() method class GFG { public static void main(String[] args) { // Double value Double a = 17.47; // wrapping the Double value // in the wrapper class Double Double b = new Double(a); // doubleValue of the Double Object double output = b.doubleValue(); // print doubling the output System.out.println("Double value of " + b + " is : " + output); }}
输出
Double value of 17.47 is : 17.47
程序2
// Java code to demonstrate// Double doubleValue() method class GFG { public static void main(String[] args) { String value = "54.1"; // wrapping the Double value // in the wrapper class Double Double b = new Double(value); // doubleValue of the Double Object double output = b.doubleValue(); // print doubling the output System.out.println("Double value of " + b + " is : " + output); }}
输出
Double value of 54.1 is : 54.1
