#847 – How the Call Stack Works

A call stack is an indication of which method in your application is currently executing and how the application got there.  When a method is called, information about that method is pushed onto the call stack.  When the method returns to its caller, that information is popped back off the stack.  In this way, the top of the stack always refers to the current method.  And, traversing down the stack, we see the sequence of calls that got us to the current method.

For example, assume that when your application starts, a Main method is called.  Information about Main is pushed onto the stack.


Assume that Main then creates an instance of a Dog object and calls its BarkYourAge method.


If BarkYourAge then calls method DogUtil.GenerateBark, we get:


When control returns from GenerateBark, we continue in the BarkYourAge method and the stack becomes:



About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #847 – How the Call Stack Works

  1. Pingback: Dew Drop – May 20, 2013 (#1,550) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: