Interface Stack<T>

All Known Implementing Classes:
ArrayListStack

public interface Stack<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
    Tests if stack is empty.
    Returns item from the top of the stack.
    pop()
    Removes and returns item from the top of the stack.
    push(T x)
    Adds an item to the top of the stack.
    int
    Returns the size of the stack.
  • Method Details

    • push

      T push(T x)
      Adds an item to the top of the stack.
      Parameters:
      x - the item to add.
      Returns:
      the item added.
    • pop

      T pop()
      Removes and returns item from the top of the stack.
      Returns:
      the former top item.
      Throws:
      EmptyStackException - if stack is empty.
    • peek

      T peek()
      Returns item from the top of the stack.
      Returns:
      the top item.
      Throws:
      EmptyStackException - if stack is empty.
    • empty

      boolean empty()
      Tests if stack is empty.
      Returns:
      true if the stack is empty; false otherwise.
    • size

      int size()
      Returns the size of the stack.
      Returns:
      the size of the stack.
    • clear

      void clear()