| Author |
Runtime Excepiton and Checked Exception
|
chun-ju Lin
Greenhorn
Joined: Feb 18, 2004
Posts: 6
|
|
I only know that if I don't want to "try and catch" a Checked Exception,I can "throws" it away,and if I want to show some mistake message,I can "throw" a Runtime Excepiton/Checked Exception object in a method. If I "throw" a Checked Exception object in a method ,I have to "throws" it in the method declearation,or it will compile error. My problem is that,"if we throw a Runtime Excepitonobject,why don't we need to throws it?". What time shoud we "throws" a Runtime Excepiton ?
|
 |
Chengwei Lee
Ranch Hand
Joined: Apr 02, 2004
Posts: 884
|
|
Usually we don't throw any runtime exception(s) at all. As an application developer, we're more concerned with checked exceptions (since we're more likely able to recover from such exceptions). Runtime exceptions, on the other hand, when they occurred, usually can't be recovered, hence, even if we were to catch it, there's really nothing we can do to recover from it. For e.g., if the JVM is out of memory, even if you catched that exception, there's really nothing you can do to resolve that issue. Hope this helps.
|
SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
|
 |
chun-ju Lin
Greenhorn
Joined: Feb 18, 2004
Posts: 6
|
|
Thank you ,but I still hadn't get the point. My text book wrote that ,"Excepiton" is what we can control and "Error" is what we can't control . Maybe what you talked about is "Error",not"Runtime Exception". Please tell me.
|
 |
 |
|
|
subject: Runtime Excepiton and Checked Exception
|
|
|