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