O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Closer Look at Throwable

Up to this point, we have been catching exceptions, but we haven’t been doing anything with the exception object itself. As the preceding examples all show, a catch clause specifies an exception type and a parameter. The parameter receives the exception object. Since all exceptions are subclasses of Throwable, all exceptions support the methods defined by Throwable. Several commonly used ones are shown in Table 9-1.

Image

Table 9-1 Commonly Used Methods Defined by Throwable

 

Of the methods defined by Throwable, two of the most interesting are printStackTrace( ) and toString( ). You can display the standard error message ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required