DRAFT
StringLengthField
Misconception:
String
objects have a length
field that contains the length of the string.
Incorrect
One can know the length of a String object by accessing its length field
Correct
One can know the length of a String object by calling its length method
OriginWhere could this misconception come from?
Where could this misconception come from?
If students know about arrays, they might reason using an inappropriate analogy and thus believe that objects of class String
have a length field (since arrays indeed have a final instance variable named length
).
Language
Java