Misconception: Students have trouble distinguishing between instance variables and parameters in Java.

Like(1912 Likes)
  • You can remedy this by using different names for instance variables and parameters when providing sample code in Java.
    • Consider these two versions of the same method:
      • Version 1: The following code can confuse students because the instance variable and parameter represent different things, but they have the same name.
          public void setSides(int sides) {
            this.sides = sides;
          }
      • Version 2: In the following code, having different names for the instance variable and the parameter help differentiate the two.
          public void setSides(int sides) {
            this.numSides = sides;
          }

More about this tip

External Source
Interview with Dave Musicant.