A stack underflow occurs when trying to remove an object from the operand stack, but the stack is empty.
A stack is a last in first out (LIFO) abstract data type. Elements can only be added to and removed from the peak (end) of the stack.
When the pop()
method is used on an empty stack, the program will give a stack underflow error as there is no element to be removed.
See also: stack-overflow