This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding Throwable" Watch "regarding Throwable" New topic
Author

regarding Throwable

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 417
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.

regards,
Majid


SCJP1.4, SCWCD1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding Throwable
 
Similar Threads
Throwable and Error Classes
Exception Handling(Checked/Unchecked)
wirte my own Exception throw
Throwable array
Constructor