This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime exception when to handle them

 
Ram Shree
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime exceptions are exceptions which are NOT enforced by compiler to handle them in compile time.

Since it will difficult for the programmer to anticipate in advance and handle them correctly in the code.
So how does this really help the programmer ? i mean very purpose of handling an exception is not served ? Please clarify.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We're not generally expected to handle RuntimeExceptions in our code because they are usually caused by programming bugs, and therefore it is usually meaningless or even impossible to handle it. It's a completely different family of exceptions.

We can still catch them, and we typically do at major architectural boundaries. For instance, an app server would catch any RuntimeExceptions that any of its installed apps would throw, so that one app misbehaving won't bring down others.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic