The unchecked exceptions classes are the class RuntimeException and its
subclasses, and the class Error and its subclasses. All other exception classes are checked exception classes.
I think that exception extending from Exception is a checked exception if it's not a RuntimeException.Hence, the exception extending from Exception is a checked exception...
The unchecked exceptions classes are the class RuntimeException and its
subclasses, and the class Error and its subclasses. All other exception classes are checked exception classes.
Originally posted by Sandeep MP:
Hi,
Please note that the method temp() does not throw any exception.
However when this code snippet is compiled, I don't get any error![]()
This makes me think that Exception is Unchecked.However the JLS conveys that Exception is Checked. Please let me what you think about this.
Thanks for trying to help me,
Sandeep
Originally posted by Sandeep MP:
Ok folks, I now understand it. Thanks.![]()
![]()
Hey Tilo, can you please send me an example that compiles with only try block and having no matching catch or finally block. I tried doing the same but got a compiler error.
Cheers,
Sandeep
public static void main(String[] args){//1
try {
temp();
}//try
catch (MyException e){ //2 a little change
}//catch()
}//main()
static void temp(){//3
}//temp()
}//class
Originally posted by Enrique Villamizar:
Hi:
I was wondering if someone could tell me how to handle user-defined exception(checked). In fact, I need a plain explanation about the difference between throws and throw keywords. I think throw is needed when you use your own checked exceptions?!?
Consider Paul's rocket mass heater. |