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

throw and throws

 
Manikantan Nair
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me the differences between throw and throws in detail please....
thanks
 
SRI PARUCHURI
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
throw
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();
throws
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.
Regards,
Sri
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic