• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime Excepiton and Checked Exception

 
chun-ju Lin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
chun-ju Lin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic