你的位置:首页 > Java教程

[Java教程]1.3.2 更强的数值文本表示法


Demo:

public class CoinNumText {    public static void main(String[] args) {        /** 1. 二进制文本 **/    int xBeforeJava7 = Integer.parseInt("11001100", 2);    int xJava7 = 0b11001100;    /** 2. 数字中的下划线 **/    long anotherLong = 2_147_483_648L;    int bitPattern = 0b0001_1100__0011_0111__0010_1011__1010_0011;        /** print **/    System.out.println(xBeforeJava7);    System.out.println(xJava7);    System.out.println(anotherLong);    System.out.println(bitPattern);      }}

Ran As Java Application:

2042042147483648473377699