Talk:Exception Handling in Java
This article has very big clear explanation on One of the most important concept of java that is Exception Handling. How to write the code to handle it. Most importantly three rules to avoid exception are given like avoid returning values from methods etc.Exceptions are good to handle with care using inbuilt exception classes. Exception handling decreases the chances of breaking application in the middle of the execution.
Step by step instructions with easy going explanation is given with complete code example that are tested well.This articles gives every developers a clear idea on exception handling and the usage of it and with precautions on how to avoid such exceptions.
This is a very well-written discussion on the topic of exception handling in Java. This article would serve as a very useful introduction to anybody new to exception handling in Java. Unlike many other languages, Java “forces” the developer to cater for exceptions in certain circumstances, such as when performing input and output operations.
The author manages to cover several aspects of exception handling in a concise, easy to understand manner. The code examples provided help to clearly illustrate the points made. The article also puts forward three “rules” for handling exceptions, all of which are very valid. Too often, inexperienced programmers will merely “swallow” exceptions. This should almost always be avoided, as an exception indicates that something has gone wrong and code should be written to address the problems which have occurred. Typical examples of code that is needed to handle an exception would be to display an error message or to close a connection.
It was nice to see a nice clear discussion on handling exceptions at different levels and a discussion on when to use the try…catch block and when to use the “throws” syntax. Perhaps one thing that this example lacks is an explanation of the syntax involved. The role of the “finally” block was not explained. In Java this code will always be executed, and is typically used to free up resources and close connections, whether or not an exception has occurred.