W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
我們可以在數(shù)字字面量中的兩位數(shù)字之間使用下劃線。
例如,一個int文字2014可以寫成2_014,20_14,201_4。
允許以八進制,十六進制和二進制格式使用下劃線。
int下劃線大數(shù)字使得它們更容易閱讀。
以下示例顯示數(shù)字字面量中下劃線的有效用法:
int x1 = 2_014; // Underscore in deciaml format int x2 = 2___014; // Multiple consecutive underscores int x3 = 02_014; // Underscore in octal literal int x4 = 0b0111_1011_0001; // Underscore in binary literal int x5 = 0x7_B_1; // Underscores in hexadecimal literal byte b1 = 1_2_7; // Underscores in decimal format double d1 = 2_014.01_11; // Underscores in double literal
在數(shù)字字面量中只允許在數(shù)字之間使用下劃線。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: