This section introduces you the concept of logging exception handling. When certain conditions are not followed or wrong then compiler shows a message which is mentioned under the specific exception. Exception is an event that occurred when the program is execute or in running time. This is used for the error handling. There are several errors are caught by different specific exceptions like the "divided by zero" error is under the ArithmeticException, blank array is under the NullPointerException, blank stack is a EmptyStackException and many others errors are handled by many exceptions like that.
Description of program:
This program represents two exceptions like: ArithmeticException and NullPointerException by Logger object. Program contains two method DivByZero() method and ArrayBound() method which provides an exception at the running time of program. The DivByZero method throws ArithmethicException because '1' is not divisible by '0' and another method gives the working illustration of NullPointerException that catch the error when the array is blank.
Description of code:
log(Level level, String message, Throwable thrown):
Above method shows a log message generated by Throwable information to the system. It takes level provided by logger and also a string type value with given message and throwable information at the time of running.
Here is the code of program:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: February 22, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles