I ran your code and obtained this output
campbell@********-laptop:~/java$ java JavaStackExample
stack.size()=5
Values are in stack = 12
Values are in stack = 23.6755
Values are in stack = Srinivas
Values are in stack = A
i=4
Employee =Srinivas : 163052campbell@********-laptop:~/java$
I couldn't reproduce the error you suffered.
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.