W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
此方法接受Number作為參數(shù),并基于調(diào)用的方法返回基本類型。 以下是可用的方法列表 -
byte byteValue() short shortValue() int intValue() long longValue() float floatValue() double doubleValue()
參數(shù) - 無需參數(shù)。
返回值 - 返回值是根據(jù)調(diào)用的值函數(shù)返回的原始類型。
以下是方法值的用法示例。
class Example { static void main(String[] args) { Integer x = 5; // Converting the number to double primitive type println(x.doubleValue()); // Converting the number to byte primitive type println(x.byteValue()); // Converting the number to float primitive type println(x.floatValue()); // Converting the number to long primitive type println(x.longValue()); // Converting the number to short primitive type println(x.shortValue()); // Converting the number to int primitive type println(x.intValue()); } }
當我們運行上面的程序,我們將得到以下結(jié)果 -
5.0 5 5.0 5 5 5
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: