Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try:</p> <pre><code> Node(K data) { this(); this.data = data; } </code></pre> <p>The call to the "other" constructor needs to be always first. The call to the other constructors from inside a constructor is always done with <code>this(...)</code> not with <code>Node(...)</code>.</p> <p><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8.7" rel="nofollow">JLS section 8.8.7</a> specify how the constructor body should look like:</p> <blockquote> <p>ConstructorBody: { ExplicitConstructorInvocation(opt) BlockStatements(opt) }</p> </blockquote> <p>where <code>ExplicitConstructorInvocation(opt)</code> is either an alternate constructor or a constructor from the parent class invoked with <code>super(...)</code>.</p> <p>and <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.5" rel="nofollow">JLS section 12.5</a> specify the object initialization steps when a constructor is called:</p> <blockquote> <p>Just before a reference to the newly created object is returned as the result, the indicated constructor is processed to initialize the new object using the following procedure:</p> <ul> <li><p>Assign the arguments for the constructor to newly created parameter variables for this constructor invocation.</p></li> <li><p>If this constructor begins with an explicit constructor invocation (§8.8.7.1) of another constructor in the same class (using this), then evaluate the arguments and process that constructor invocation recursively using these same five steps. </p></li> </ul> <p>...</p> </blockquote> <p><strong>These JLS rules make sure that the parent class constructor is called first and once.</strong></p>
    singulars
    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.
 

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