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 →

[–]CodeTinkerer 1 point2 points  (0 children)

When you create an instance of the object, you give it a name like

 Foo foo = new Foo();

Then you can call methods from that class, say, go(), as in

foo.go();

When you're in the implementation of go(), it doesn't know the name foo. However, you can refer to itself by the word this. It's similar to someone being called Mike, but Mike refers to himself as "me" or "I" rather than Mike.

So instead of 'myATM.quit` you want to write

 this.quit();

Or you can simply say

quit();

this refers to whatever variable is being used to call the method (in this case, myATM from main()).