ThisExistsInStaticMethod
Misconception:
this
is a special local variable,
stored in the stack frame of any static method.
Incorrect
this is a local variable, also in static methods
Correct
this does not exist in static methods
CorrectionHere is what's right.
Here is what's right.
this
is a special kind of local variable that only exists in instance methods.
It refers to the object the instance method is operating on.
A static method does not operate on an object,
and thus a this
variable makes no sense in that case.
SymptomsHow do you know your students might have this misconception?
How do you know your students might have this misconception?
- When drawing stack frames of static methods, students include
this
Language
Java