
742 CHAPTER 11 Exceptions and Input/Output Operations
TABLE 11.1 Useful Methods of Exception Classes
Useful Methods of Exception Classes
Return value Method name and argument list
String getMessage( )
returns a message indicating the cause of the exception
String toString( )
returns a String containing the exception class name and a
message indicating the cause of the exception
void printStackTrace( )
prints the line number of the code that caused the exception,
along with the sequence of method calls leading up to the
exception
We prompt the user and echo the input on lines 14–17. Then we define a
try block (lines 19–24) and insert the parseInt method call ...