Java Stacks

The Java collections framework has a class named Stack that provides the functionality of the stack data structure. The Stack class extends the Vector class.

Figure 2.11: Java Stacks
Image javastack

In stack, elements are stored and accessed in Last In First Out manner. That is, elements are added to the top of the stack and removed from the top of the stack.

Figure 2.12: Stacks implementation
Image stackimplementation



Subsections