среда, 30 октября 2019 г.

Number notation

int million2 = 1_000_000;

You can add underscores anywhere except at the beginning of a literal, the end of a literal, right before a decimal point, or right after a decimal point.


Let’s look at a few examples:

double notAtStart = _1000.00; // DOES NOT COMPILE

double notAtEnd = 1000.00_; // DOES NOT COMPILE

double notByDecimal = 1000_.00; // DOES NOT COMPILE

double annoyingButLegal = 1_00_0.0_0; // this one compiles

Комментариев нет:

Отправить комментарий