This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes throw and throws Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "throw and throws" Watch "throw and throws" New topic

throw and throws

Manikantan Nair

Joined: Oct 13, 2000
Posts: 13
Can anybody tell me the differences between throw and throws in detail please....

Joined: Dec 17, 2000
Posts: 15
A Java(TM) programming language keyword that allows the user to throw an exception or any class that implements the "throwable" interface. A throw statement is used to cause an exception to be thrown. The expression in a throw statement must produce a reference to an object that is an instance of the Throwable class or one of its subclasses. Otherwise, the compiler issues an error message. You typically want the expression in a throw statement to produce an object that is an instance of a subclass of the Exception class.
Here is an example of a throw statement:
throw new ProtocolException();
A Java(TM) programming language keyword used in method declarations that specify which exceptions are not handled within the method but rather passed to the next higher level of the program.
I agree. Here's the link:
subject: throw and throws
It's not a secret anymore!