Q:

What was the rationale for allowing underscores between integer digits?

I stumbled across this seemingly odd statement in the JLS, section 3.10.1 (integer literals) today:

Underscores are allowed as separators between digits that denote the integer.

Lo and behold the following is completely valid (example):
int x = 1_2_3_4_5____6;

Underscores may only appear between digits, leading/trailing underscores are invalid.
What was the rationale for this? Is it some holdover from some other language? Some style that was common at the time? It seems like a rather strange thing to allow.

A:

The idea behind this is to be able to display a big number that is easily readable.
Example: int x = 1_000_000;
There are other use cases for this but this is the most used i think.
See the documentation for more information.

