Code example for EmptyStackException

0
        stack.add(t);
    } 
 
    public T pop() throws EmptyStackException { 
        if (isEmpty()) { 
            throw new EmptyStackException();
        } 
        return stack.remove(stack.size() - 1);
    } 
 
    @Override 
    public boolean isEmpty() { 
        return stack.isEmpty();
    } 
 
    public T peek() throws EmptyStackException { 
        if (isEmpty()) { 
            throw new EmptyStackException();
        } 
        return stack.get(stack.size() - 1);
    }