File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on Throwble interface

 
Anil Pattnaik
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?"
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic