aspose file tools
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 Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "throw and throws" Watch "throw and throws" New topic

throw and throws

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200

What are the differemces between throw and throws in Exception handling. Please explain with some example coding will be very useful.

I am learning in the Head First Java. In that book they mentioned DUCK IT. Anybody if uses the same book and know it please explain it.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

throw: throw a specific exception from some point in the code.
throws: flag that a method may throw a named exception. So:

[ August 22, 2005: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: throw and throws