Skip to main content
Misconception: Students have trouble distinguishing between instance variables and parameters in Java.
- 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) {
}
- 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) {
}