Although you are just learning about them now, you have probably become well-acquainted with exceptions during the last 17 previous hours. These errors turn up when you write a Java program that compiles successfully but encounters a problem when it runs.

For example, a common programming mistake is to refer to an element of an array that doesn't exist, as in the following statements:

String[] greek = { "Alpha", "Beta", "Gamma" };

In this example, the String array has three elements. Because the first element in an array is numbered 0 rather than 1, the first element is greek[0], the second is greek[1] and the third is greek[2]. The statement attempting to display the contents of greek[3] is erroneous, ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.