Number Formatting
Underscores in numeric literals
數字下劃線。
只能放在數字之間。
允許連續下劃線,10__00 仍有效,但不允許在數字後,1000_ 無效。
若在數字前加上 _100,則在 Java 中代表變量,而非數字。
Binary Integer Literals
Java 7 以前
只能使用八進制值 (帶有前綴 "0") 或十六進制值 (帶有前綴 "0x" 或 "0X" )。
Java 7 以後
可以使用二進制,透過整數類型 (byte,short,int 和long) 的帶有前綴"0b" 或"0B"。
Last updated
Was this helpful?