26 package java.util;
27
28 /**
29 * The <code>Stack</code> class represents a last-in-first-out
30 * (LIFO) stack of objects. It extends class <tt>Vector</tt> with five
31 * operations that allow a vector to be treated as a stack. The usual
32 * <tt>push</tt> and <tt>pop</tt> operations are provided, as well as a
33 * method to <tt>peek</tt> at the top item on the stack, a method to test
34 * for whether the stack is <tt>empty</tt>, and a method to <tt>search</tt>
35 * the stack for an item and discover how far it is from the top.
36 * <p>
37 * When a stack is first created, it contains no items.
38 *
39 * <p>A more complete and consistent set of LIFO stack operations is
40 * provided by the {@link Deque} interface and its implementations, which
41 * should be used in preference to this class. For example:
42 * <pre> {@code
43 * Deque<Integer> stack = new ArrayDeque<Integer>();}</pre>
44 *
45 * @author Jonathan Payne
46 * @since JDK1.0
47 */
48 public
49 class Stack<E> extends Vector<E> {
50 /**
51 * Creates an empty Stack.
52 */
53 public Stack() {
54 }
55
56 /**
57 * Pushes an item onto the top of this stack. This has exactly
58 * the same effect as:
59 * <blockquote><pre>
60 * addElement(item)</pre></blockquote>
61 *
62 * @param item the item to be pushed onto this stack.
63 * @return the <code>item</code> argument.
64 * @see java.util.Vector#addElement
65 */
66 public E push(E item) {
|
26 package java.util;
27
28 /**
29 * The <code>Stack</code> class represents a last-in-first-out
30 * (LIFO) stack of objects. It extends class <tt>Vector</tt> with five
31 * operations that allow a vector to be treated as a stack. The usual
32 * <tt>push</tt> and <tt>pop</tt> operations are provided, as well as a
33 * method to <tt>peek</tt> at the top item on the stack, a method to test
34 * for whether the stack is <tt>empty</tt>, and a method to <tt>search</tt>
35 * the stack for an item and discover how far it is from the top.
36 * <p>
37 * When a stack is first created, it contains no items.
38 *
39 * <p>A more complete and consistent set of LIFO stack operations is
40 * provided by the {@link Deque} interface and its implementations, which
41 * should be used in preference to this class. For example:
42 * <pre> {@code
43 * Deque<Integer> stack = new ArrayDeque<Integer>();}</pre>
44 *
45 * @author Jonathan Payne
46 * @since 1.0
47 */
48 public
49 class Stack<E> extends Vector<E> {
50 /**
51 * Creates an empty Stack.
52 */
53 public Stack() {
54 }
55
56 /**
57 * Pushes an item onto the top of this stack. This has exactly
58 * the same effect as:
59 * <blockquote><pre>
60 * addElement(item)</pre></blockquote>
61 *
62 * @param item the item to be pushed onto this stack.
63 * @return the <code>item</code> argument.
64 * @see java.util.Vector#addElement
65 */
66 public E push(E item) {
|