You are using the stack incorrectly; you are using it as a List. It is a bit of bad design that Stack extends Vector, but if you use it as a stack you should only use the push() pop() peek() and isEmpty() methods.