Program Termination

In the sample executions of Fig. 11.2 when exceptions occur and stack traces are displayed, the program also exits. This does not always occur in Java. Sometimes a program may continue even though an exception has occurred and a stack trace has been printed. In such cases, the application may produce unexpected results. For example, a graphical user interface (GUI) application will often continue executing. In Fig. 11.2 both types of exceptions were detected in method main. In the next example, we’ll see how to handle these exceptions so that you can enable the program to run to normal completion.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.