The class stack implements a stack (also known as LIFO). With push(), you can insert any number of elements into the stack (Figure 12.1). With pop(), you can remove the elements in the opposite order in which they were inserted (“last in, first out”).