File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 24184
    
  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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on Throwble interface