File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes regarding Throwable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding Throwable" Watch "regarding Throwable" New topic

regarding Throwable

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
when i write throw new Throwable(),it is working.I wonder how we can write new in front of an interface because Throwable has no constructor,so how it is possible.Any comments.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Throwable isn't an interface, it's a class.

You are correct in your idea that you cannot instantiate an interface directly. But this is not relevant to Throwable, as it's a class.

Note that you should never instantiate Throwable directly, in any real application. It is legal Java to do so, but very bad practice. You should only instantiate Exception, RuntimeException or Error, or (better) their subclasses.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Majid Al-Fifi
Ranch Hand

Joined: Aug 22, 2006
Posts: 45
I also thought Throwable is an Interface.


I agree. Here's the link:
subject: regarding Throwable
It's not a secret anymore!