Class Stack

  • All Implemented Interfaces:
    java.io.Serializable

    public class Stack
    extends java.lang.Object
    implements java.io.Serializable
    A unbounded stack.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Stack()
      Construct a new, empty stack.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears this stack.
      java.lang.Object first()
      Returns the first element of the stack.
      boolean isEmpty()
      Returns true if the stack is empty.
      java.lang.Object last()  
      java.lang.Object pop()
      Pops from this stack.
      void push​(java.lang.Object obj)
      Push into this stack.
      void remove​(java.lang.Object o)  
      int size()
      Returns the number of elements in the stack.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Stack

        public Stack()
        Construct a new, empty stack.
    • Method Detail

      • clear

        public void clear()
        Clears this stack.
      • pop

        public java.lang.Object pop()
        Pops from this stack.
        Returns:
        null, if this stack is empty or the element is really null.
      • push

        public void push​(java.lang.Object obj)
        Push into this stack.
      • remove

        public void remove​(java.lang.Object o)
      • first

        public java.lang.Object first()
        Returns the first element of the stack.
        Returns:
        null, if the stack is empty, or the element is really null.
      • last

        public java.lang.Object last()
      • isEmpty

        public boolean isEmpty()
        Returns true if the stack is empty.
      • size

        public int size()
        Returns the number of elements in the stack.