doublevalue
Double类doubleValue()方法 (Double class doubleValue() method)
doubleValue() method is available in java.lang package.
doubleValue()方法在java.lang包中可用。
doubleValue() method is used to return the value denoted by this Double object converted to type double (by casting).
doubleValue()方法用于返回此Double对象表示的值,该值转换为double类型(通过强制转换)。
doubleValue() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
doubleValue()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
doubleValue() method does not throw an exception at the time of conversion from Double to double.
从Double转换为double时, doubleValue()方法不会引发异常。
Syntax:
句法:
public double doubleValue();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is double, it returns a converted (from type Double to double) value represented by this Double object.
此方法的返回类型为double ,它返回由此Double对象表示的转换后的值(从Double类型转换为double )。
Example:
例:
// Java program to demonstrate the example
// of doubleValue() method of Double class
public class DoubleValueOfDoubleClass {
public static void main(String[] args) {
// Variables initialization
double d1 = 18.20;
double d2 = 19.20;
// It returns double value denoted by this Double do1 object
// and converted to a double by calling do1.doubleValue()
Double do1 = new Double(d1);
// Display do1 result
System.out.println("do1.doubleValue(): " + do1.doubleValue());
// It returns double value denoted by this Double do2 object
// and converted to a double by calling do2.doubleValue()
Double do2 = new Double(d2);
// Display do2 result
System.out.println("do2.doubleValue(): " + do2.doubleValue());
}
}
Output
输出量
do1.doubleValue(): 18.2
do2.doubleValue(): 19.2
翻译自: https://www.includehelp.com/java/double-class-doublevalue-method-with-example.aspx
doublevalue