aspose file tools*
The moose likes Beginning Java and the fly likes Difference between Throws and Throw Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between Throws and Throw" Watch "Difference between Throws and Throw" New topic
Author

Difference between Throws and Throw

satya sahu
Ranch Hand

Joined: Mar 26, 2003
Posts: 97
Hi all, can somebody tell me the difference between throws and throw with some good example.
Thanks in advance.

satya
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

"throws": used to announce a method may throw an exception, so you need to handle it in code that uses the method.
"throw": actually throws an exception.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
throws say it might throw sometime in the future
throw does the throwing NOW

Brian


My Java Freeware:<br />MACCC - <a href="http://maccc.pipasoft.com" target="_blank" rel="nofollow">http://maccc.pipasoft.com</a><br />Nator - <a href="http://nator.pipasoft.com" target="_blank" rel="nofollow">http://nator.pipasoft.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Throws and Throw