stack : Java Glossary

stack
A stack is a sort of LIFO (Last In First Out) queue. Stacks behave like the stacking trays at a cafeteria. The JVM (Java Virtual Machine) uses a hidden stack to keep track of which method called which method and with what parameters. Every thread has its own private stack of about one megabyte. There is no Collection called Stack, but is fairly easy to write one. Adding to a stack is called pushing and retrieving the top element is called popping. Discarding the top element is called dropping. Duplicating the top element is called duping.

In Forth and PostScript the stacks are explicit. In Java they are hidden, except for printStackTrace.

Local variables are often called stack variables because they are stored on the stack. In Java, the stack contains the local variables for each running method is the thread, and the places to return to in the calling program for each level of call. If you call too many methods without returning (usually by using recursion) you will generate a StackOverFlowError.


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/stack.html J:\mindprod\jgloss\stack.html
logo
Please email your , letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email. If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, please quote it and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. Threatening to kill me or spouting obscenities has yet to persuade me to change my mind.
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.179.211]
You are visitor number 18,990.