August 2004
Intermediate to advanced
480 pages
9h 41m
English
Stacks are like Pez dispensers. Stacks are very similar to arrays, and so we'll discuss them here. Many internal data structures are stored as stacks within Java. The stack operates on a last in, first out basis. You can create your own stack, or you can use an instance of java.util.Stack.
The java.util.Stack class extends java.util.Vector, which is a type of collection. The two main operations you use with a stack are pop() and push(). You can also peek() to see the item on the top of the stack. Finally, you can search the stack for an item, and you can determine if the stack is empty.
package net.javagarage.arrays; import java.util.Stack; /** * <p>Does stuff with java.util.Stack * @author eben hewitt */ public ...
Read now
Unlock full access