import java.util.ArrayList; //import java.util.LinkedList; /** Implement a stack data structure, in which last element added is * the first element to be removed. * @param */ public class Stack { private ArrayList a; /** Creates a new empty Stack * */ public Stack(){ a = new ArrayList(); } /** Adds an object to the stack. * @param o The object to be added to the stack. * @return Returns true if object was successfully added and false otherwise. */ public boolean push(E o){ return a.add(o); } /** Removes an object from the stack. * @return Returns the object. */ public E pop(){ return a.remove(a.size()-1); } /** Tells whether the stack is empty or not. * @return Returns true if the stack is empty and false otherwise. */ public boolean isEmpty(){ return a.isEmpty(); } }