Lecture 21
6
Stack
•The call stack
–grows each time a message invokes a method
–shrinks each time a method returns
•main() is always the first thing pushed on to the stack and the last to pop off: when main is done the program is done
•In CS a stack is a last in first out collection
–push adds an item to the stack
–pop removes one
•The call stack
–push a method when it’s invoked
–pop a method when it returns