Various methods to print exception information:
• A throwable class defines the following methods to print exception information to the console.
printStackTrace(): This method prints exception information in the following format.
Name of the exception: description of the exception
Stack trace
toString(): This method prints exception information in the following format.
Name of the exception: description of the exception
getMessage(): This method returns the only description of the exception.
Description.
Example:
Note: Default exception handler internally uses the printStackTrace() method to print exception
information to the console.
Comments
Post a Comment