Class ArrayStack<T>

  • Type Parameters:
    T - data to keep in stack

    public class ArrayStack<T>
    extends Object
    Custom stack
    • Constructor Detail

      • ArrayStack

        public ArrayStack​(int initSize)
        Create
        Parameters:
        initSize - - book the size
    • Method Detail

      • push

        public void push​(T obj)
        Add the element to the head
        Parameters:
        obj - - data to be added
      • pop

        public T pop()
        Get the head and remove it from the stack
        Returns:
        the head
      • isEmpty

        public boolean isEmpty()
        Check
        Returns:
        true when it contains nothing
      • clear

        public void clear()
        remove all items in the stack