The pop method from the LinkedStack Class Figure 611 stores
The pop() method from the LinkedStack Class (Figure 6-11) stores the element being popped in a temporary variable result. Why doesn\'t the pop() method from ArrayStack (Figure 5-16) need to do this ?
Cheers and thank you!
Solution
The pop() method can throw an EmptyStructureException that is the reason it need to do this and the following program gives
public Object pop()
{
if (isEmpty())
{
throw new EmptyStructureException();
}
size--;
return data[size];
}
