Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You don't <strong>have</strong> to use "_", you <strong>can</strong>. And examples given in the proposal are credit card numbers, phone numbers, or simply numbers for which it makes sense to have a separator in the code.</p> <p>For the "In positions where a string of digits is expected" it's simply in places where it's supposed to start (or end) with a digit. Here are some examples.</p> <blockquote> <p>Note that according to this proposal, underscores can only be placed between digits. They cannot be placed by themselves in positions where a string of digits would normally be expected:</p> <p>int x1 = _52; // This is an identifier, not a numeric literal.</p> <p>int x2 = 5_2; // OK. (Decimal literal)</p> <p>int x2 = 52_; // Illegal. (Underscores must always be between digits)</p> <p>int x3 = 5_______2; // OK. (Decimal literal.)</p> <p>int x4 = 0_x52; // Illegal. Can't put underscores in the "0x" radix prefix.</p> <p>int x5 = 0x_52; // Illegal. (Underscores must always be between digits)</p> <p>int x6 = 0x5_2; // OK. (Hexadecimal literal)</p> <p>int x6 = 0x52_; // Illegal. (Underscores must always be between digits)</p> <p>int x6 = 0x_; // Illegal. (Not valid with the underscore removed)</p> <p>int x7 = 0_52; // OK. (Octal literal)</p> <p>int x7 = 05_2; // OK. (Octal literal)</p> <p>int x8 = 052_; // Illegal. (Underscores must always be between digits)</p> </blockquote> <hr> <p><strong>Resources:</strong></p> <ul> <li><a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001628.html" rel="noreferrer">OpenJDK - Project Coin - PROPOSAL: Underscores in Numbers (Version 2)</a></li> <li><a href="http://blogs.oracle.com/darcy/entry/project_coin_literal_grammar_hackery" rel="noreferrer">Joe Darcy's blog - Project Coin: Project Coin: Literal Grammar Hackery</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload