Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your constructor accepts <code>String, String</code>, but you're passing <code>String, int, String</code>.</p> <p>Either add an <code>int</code> parameter to the constructor, or remove the <code>int</code> from the call.</p> <p>My suggestion is to add an int parameter, ie change your constructor to this:</p> <pre><code>public PassTheClass (String xMyName, int xMyGrade, String xMyEmotion) { myName = xMyName; myGrade = xMyGrade; myEmotion = xMyEmotion; } </code></pre> <p>If you still need the <code>String, String</code> constructor, change it to call the 3-arg one and pass in the initial value you currently have coded:</p> <pre><code> public PassTheClass (String xMyName, String xMyEmotion) { this(xMyName, 0, xMyEmotion); } </code></pre> <hr> <p>Although there's nothing "wrong" about prefixing parameters with "x" to distinguish them from field names, I have never seen such a thing done. The convention in java is to use the same name for the parameter as the field name and use <code>this.</code> when assigning, like this</p> <pre><code>public PassTheClass (String myName, int myGrade, String myEmotion) { this.myName = myName; this.myGrade = myGrade; this.myEmotion = myEmotion; } </code></pre> <hr> <p>As a further "style" improvement, don't prefix your field names with "my". <em>Every</em> field is implicitly "my" something; just name them plainly, ie <code>name</code>, <code>grade</code> and <code>emotion</code>. </p> <hr> <p>Good code is all about <em>clarity</em>: Prefer avoiding prefixes, as they just clutter the code and reduce readability.</p>
 

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