Hi, I am confused at the checked/unchecked Exception. How can I know which one is the checked Exception need to catch in the program, and which one is the unchecked Exception needn't to catch in the program. thanks Krussi
Checked exceptions are any classes that extend the exception class, excluding the class RuntimeException. RuntimeException and its descendents make up the set of unchecked exceptions. Note that the class Exception, itself, is an unchecked exception. I hope that helps, Corey
As Corey has explained checked and unchecked exceptions are based on the fact what exception class do they extend. SO to figure out whether to catch an exception in program or not you have to traverse the hierarchy to see if its an RunTime Exception or is in subtree of exception class (not under checked exception subtree - user defined exception). You will have to refer to documentation to find out about pre-defined exceptions and further the API documentation should indicate about the exceptions the API throws. hope that was helpful
Originally posted by Jessica Sant: Don't forget the java.lang.Error Class -- it's decendents are also not checked.
But don't get errors confused with exceptions. The class Error and Exception are siblings. Errors are not exceptions and vice versa. Each class extends Throwable. But, like Jessica said, Errors are unchecked. Corey