Numeric literals with underscores
Numerical literals are definitely eye strainers. I am sure you would start counting the zeroes like me if you’ve been given a number with, say, ten zeros. It’s quite error prone and cumbersome to identify a literal if it’s a million or a billion unless you count the places from right to left. Not anymore. Java 7 introduced underscores in identifying the places. For example, you can declare 1000 as shown below:
int thousand = 1_000;
or 1000000 (one million) as follows
int million = 1_000_000
Note that binary literals are also introduced in this release too — for example “0b1” — so developers don’t have to convert them to hexadecimals any more.