AP® Computer Science A glossary

Call stack

Also called: stack of calls

Course: AP® Computer Science A Shows up in: Unit 4: Data Collections

The list Java keeps of method calls that have started but not yet returned, each with its own parameters and local variables.

Appears in the course and exam description (CED): 4.16.A.2

Each time a method is called, Java adds it to the top of the call stack; when it returns, it is removed and the call below it continues. In recursion every waiting call keeps its own parameter values, which is why tracing tables list one row per call.

Example

// sumDigits(407) is waiting for sumDigits(40),
// which is waiting for sumDigits(4) (the base case).
// Each call has its own n: 407, 40 and 4.
Learn it properly, with a checkpoint 4.16 Recursion

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure