Java Exceptions

At this point in the book, it's likely that you've run into at least one Java exception— perhaps you mistyped a method name or made a mistake in your code that caused a problem. Maybe you tried to run a Java applet written using version 2 of the language in a browser that doesn't support it yet, and saw a Security Exception message on the browser's status line.

Chances are, a program quit and spewed a bunch of mysterious errors to the screen. Those errors are exceptions. When your program quits, it's because an exception was thrown. Exceptions can be thrown by the system, thrown by classes you use, or intentionally thrown in your own programs.

The term thrown is fitting because exceptions also can be caught. Catching an exception ...

Get Sams Teach Yourself Java 2 in 21 Days, Second 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.