We can use underscores between two digits in numeric literals.
For example, an int literal 2014 can be written as 2_014, 20_14, 201_4.
The use of underscores is allowed in octal, hexadecimal, and binary formats.
int underscores in big numbers makes them easier to read.
The following examples show the valid uses of underscores in numeric literals:
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
Underscores are allowed in numeric literals only between digits.