This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Doubt on Throwble interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt on Throwble interface" Watch "Doubt on Throwble interface" New topic

Doubt on Throwble interface

Anil Pattnaik

Joined: Jun 15, 2006
Posts: 8
Hello everybody,

In Exception handling,if we want our own exceptions to be thrown we have to extend Exception class or we have to implement throwable interface.I could not understand what is the use of throwable it does not specify any methods inside it.So,why we implement Throwable interface?please Explain clearly......Thank u.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

There is no "Throwable interface" -- Throwable is actually a class, the parent of "Exception" and "Error". All the useful methods of Exception are actually defined in Throwable; it's "Exception" whose Javadocs suggest that it is an empty class.

When defining an exception, you normally extend Exception or RuntimeException; these are the parent classes of "normal" exceptions that occur during program execution. "Error" is the parent of abnormal error conditions like "out of memory" or "internal error". Although nothing prevents you from extending Throwable directly, it would be a bad practice; normally "catch (Exception ex)" should be able to catch all normal exceptions.

So, are you going to tell us where you heard about this "Throwable interface?"

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Doubt on Throwble interface
Similar Threads
Constructors of unimplemented Exceptions
throw Exception
error pages in dd
Ambiguious Questions...