import java.lang.StringBuffer;
class AStack<E> implements Stack<E> {
private E stackArray[];
private static final int DEFAULT_SIZE = 10;
private int maxSize;
private int top;
@SuppressWarnings("unchecked")
AStack(int size) {
maxSize = size;
top = 0;
stackArray = (E[])new Object[size];
}
AStack() { this(DEFAULT_SIZE); }
public void clear() { top = 0; }
public boolean push(E it) {
if (top >= maxSize) { return false; }
stackArray[top++] = it;
return true;
}
public E pop() {
if (top == 0) { return null; }
return stackArray[--top];
}
public E topValue() {
if (top == 0) { return null; }
return stackArray[top-1];
}
public int length() { return top; }
public boolean isEmpty() { return top == 0; }
}