/Users/petercappello/NetBeansProjects/56-2014/56-2014-example-JUnit/src/Stack.java
import java.util.LinkedList;
import java.util.List;

/**
 * A stack of objects of type T.
 * @author Peter Cappello
 */
public class Stack<T> 
{
    private final List<T> stack = new LinkedList<>();
    
    /**
     * Answers the question is the stack empty.
     * @return true if and only if it is empty.
     */
    public boolean isEmpty() { return stack.isEmpty(); }
    
    /**
     * Removes and retrieves the stack's top element.
     * @return the top of the stack.
     * @throws IndexOutOfBoundsException when the stack is empty.
     */
    public T pop() { return stack.remove( 0 ); }
    
    /**
     * Inserts an element into the stack.
     * @param element 
     */
    public void push( T element ) { stack.add( 0, element ); }
    
    /**
     * Retrieves but does not remove the top element of the stack.
     * @return the top element of the stack.
     */
    public T peek() { return stack.get( 0 ); }
}