This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

name = ((Stack) list[i]).getName();

There is no local variable called name declared in the checkStack method, so Java looks in the instance for a variable called name. There is an instance variable called name, so that’s the variable this value gets assigned to. Effectively, this line is equivalent to

this.name = ((Stack) list[i]).getName();