Chapter 6: Exceptions in Java

6.1 Introduction

Exceptions occur when a part of a program, such as a method, encounters a problem that it cannot handle correctly. These problems are not necessarily bugs; they could be such situations as a user entering invalid input that cannot be handled in the current method. Often the programmer has made allowances for these problems, but to keep the methods in the program as generic as possible, programs are designed so that these problems are handled outside of the method where they occur.

Developing a good strategy for handling exceptions in a normal, non-concurrent program is not an easy or straightforward task. A number of decisions must be made when deciding on how to handle exceptions and errors. What ...

Get Creating Components 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.