Modify the source code for the Stack class from Chapter 17, shown in Displays 17.17 through 17.19. Currently, if the user of the class attempts to pop from an empty stack the program prints out an error message and exits. Modify the program so that it instead throws an exception named PopEmptyStackException.
Write a main function that tests the new Stack class, attempts to pop from an empty stack, and catches the PopEmptyStackException exception.
Sorry the answer is not available at the moment…
If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.
Spread the 'tradition of sharing'.