We will be implementing a stack using an ArrayList<E>. An array is a random access data structure. This means that each element can be accessed directly and in constant time. An ArrayList is not necessarily the perfect data structure, in fact a LinkedList might be better. However, the mapping of a stack onto an ArrayList will help you understand the function of a stack.

A stack is considered a limited access data structure - elements can be added and removed from the stack only at the top.

Common applications

Used in situations where you want to process the most recent additions to the stack before processing the previous entries.

The following image shows a conceptual image of a stack:

https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm