doublevalue_Java Integer类doubleValue()方法与示例
doublevalue
整數(shù)類(lèi)doubleValue()方法 (Integer 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 Integer object converted to type double (by casting).
doubleValue()方法用于返回此Integer對(duì)象表示的值,該值轉(zhuǎn)換為double類(lèi)型(通過(guò)強(qiáng)制轉(zhuǎn)換)。
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()方法是一種非靜態(tài)方法,只能通過(guò)類(lèi)對(duì)象訪問(wèn),如果嘗試使用類(lèi)名稱(chēng)訪問(wèn)該方法,則會(huì)收到錯(cuò)誤消息。
doubleValue() method does not throw an exception at the time of conversion from Integer to double.
從Integer轉(zhuǎn)換為double時(shí), doubleValue()方法不會(huì)引發(fā)異常。
Syntax:
句法:
public double doubleValue();Parameter(s):
參數(shù):
It does not accept any parameter.
它不接受任何參數(shù)。
Return value:
返回值:
The return type of this method is double, it returns a converted (from type Integer to double) value represented by this Integer object.
此方法的返回類(lèi)型為double ,它返回此Integer對(duì)象表示的轉(zhuǎn)換后的值(從Integer類(lèi)型轉(zhuǎn)換為double類(lèi)型)。
Example:
例:
// Java program to demonstrate the example // of doubleValue() method of Integer classpublic class DoubleValueOfIntegerClass {public static void main(String[] args) {// Variables initializationint i1 = 20;int i2 = 30;// It returns double value denoted by this Integer ob1 object// and converted to a double by calling ob1.doubleValue()Integer ob1 = new Integer(i1);// Display ob1 resultSystem.out.println("ob1.doubleValue(): " + ob1.doubleValue());// It returns double value denoted by this Integer ob2 object// and converted to a double by calling ob2.doubleValue()Integer ob2 = new Integer(i2);// Display ob2 resultSystem.out.println("ob2.doubleValue(): " + ob2.doubleValue());} }Output
輸出量
ob1.doubleValue(): 20.0 ob2.doubleValue(): 30.0翻譯自: https://www.includehelp.com/java/integer-class-doublevalue-method-with-example.aspx
doublevalue
總結(jié)
以上是生活随笔為你收集整理的doublevalue_Java Integer类doubleValue()方法与示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。