Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Tokens are the individual characters and strings which have some kind of meaning.</p> <p>Tokens, as defined in <a href="http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html" rel="noreferrer">Chapter 3: Lexical Structure</a> of <a href="http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html" rel="noreferrer">The Java Language Specification</a>, are:</p> <blockquote> <p>identifiers (§3.8), keywords (§3.9), literals (§3.10), separators (§3.11), and operators (§3.12) of the syntactic grammar.</p> </blockquote> <p>The tokens in the given line are:</p> <pre><code>"(", "fitness", "&gt;", "g.fitness", ")", "?", "return", "1", ":", "return", "-1", ";" </code></pre> <p>(Whitespace also counts, but I've omitted them from the above.)</p> <hr> <p>Labels in Java are used for control of flow in a program, and is an identifier, followed by a colon.</p> <p>An example of a label would be <code>hello:</code>.</p> <p>Labels are used in conjunction with <code>continue</code> and <code>break</code> statements, to specify which control structure to <code>continue</code> or <code>break</code> to.</p> <p>There is more information on Labeled Statements in <a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.7" rel="noreferrer">Section 14.7</a> of <a href="http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html" rel="noreferrer">The Java Language Specification</a>.</p> <hr> <p>The problem here is with the <code>return</code> statement:</p> <pre><code>(fitness&gt;g.fitness) ? return 1 : return -1; ^^^^^^ </code></pre> <p>There is a <code>:</code> immediately following the <code>return 1</code>, which makes the compiler think that there is supposed to be a label there. </p> <p>However, the <code>return 1</code> is a statement in itself, therefore, there is no label identifier there, so the compiler is complaining that it was expecting an label, but it was not able to find a properly formed label.</p> <pre><code>(fitness&gt;g.fitness) ? return 1 : return -1; ^^^^^^^^ ^ statement label without an identifier </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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