import java.util.ArrayList; public class ArrayListAsStack { ArrayList stack = new ArrayList(); public ArrayListAsStack(int n) { stack.ensureCapacity(n); } public void push(Object o1) { stack.add(o1); } public Object pop() { return stack.remove(stack.size() - 1); } public Object topEle() { return stack.get(stack.size() - 1); } public boolean isEmpty() { return stack.isEmpty(); } public void clean() { stack.clear(); } }