The moose likes Beginning Java and the fly likes Runtime exception when to handle them Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Runtime exception when to handle them " Watch "Runtime exception when to handle them " New topic

Runtime exception when to handle them

Ram Shree

Joined: Nov 16, 2012
Posts: 4
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

Joined: Jan 03, 2004
Posts: 6109

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.
I agree. Here's the link:
subject: Runtime exception when to handle them
It's not a secret anymore!