Method To Print Exception Information:-
The Throwable class defines the following methods to print Exception Information.
class PrintExceptionInfo
{
public static void main(String [] args)
{
try
{
System.out.println(10/0);
}
catch(ArithmeticException e)
{
e.printStackTrace( );
System.out.println(e.toString());
System.out.println(e.getMessage());
}
}
}
Output is:-
Note: Internally default exception handler uses "printStackTrace()" method to print exception information to the console.
No comments:
Post a Comment
Be the first to comment!
Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.
Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.
Regards,
JavaByChetan
Back To Home