Posted by forax
on September 24, 2009 at 5:07 AM PDT
The second small change from coin project, new numeric litterals has been integrated to jdk7/tl workspace
and will be soon promoted into jdk7 main workspace.
The patch introduces two new notations for numeric litterals:
- Binary litteral
Litteral coded in binary starting with prefix 0b.
This prefix can be prefixed by minus for negative number.
0b11 == 3
-0b11 == -3
More examples here .
- Underscores in litterals
Allow to use underscore ('_') to separate digits in litterals.
Underscore can be used anywhere between two digits.
long aBankAccountBalance = 1_000_000_000;
long aVisaCardNumber = 1234_1234_1234_1234;
long aFrenchPhoneNumber = 01_60_95_77_33;
Of course, these two new syntax can be mixed:
int value = 0b11111111_00000000_11111111_00000000;