This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt on Throwble interface" Watch "Doubt on Throwble interface" New topic
Author

Doubt on Throwble interface

Anil Pattnaik
Greenhorn

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 interface.....as 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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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]
 
wood burning stoves
 
subject: Doubt on Throwble interface