Adding 1,2,3,4 will return 4,3,2,1. Stacks aren't the most frequently used data structure, but they are extremely useful for certain tasks. Figure 1.1 Stack before pop operation, and stack after Java provides a stack implementation, in the form of java.util.Stack. Stack's are a subclass of java.util.Vector, and share some similarities. A Vector, after all, is a queue, and a Stack is an ordered LIFO queue.
Stacks are quite easy to use.
Here's a sample application that uses a stack to reverse a list of numbers.