Java7开始,数字字面量可以加下划线(方便人类区分)

    1. public class HelloWorld {
    2. public static void main(String []args) {
    3. System.out.println(1_000_000);
    4. System.out.println(0b1111_0100_0010_0100_0000);
    5. System.out.println(0xf_42_40);
    6. System.out.println(03_641_100);
    7. }
    8. }

    image.png

    1. double x = 999_999.99;
    2. System.out.println(x);

    image.png