PDA

View Full Version : When throws keyword is used?



jerome.sturt
November 27th, 2013, 04:39 AM
When throws keyword is used?

who knows best answer for that question?

i am studying java .. still i did not get correct answers..

Toz
November 27th, 2013, 05:04 AM
Moved to the Programming Talk subforum.

Hello and welcome to the forums. I have moved your thread to a more suitable sub-forum for your question.

r-senior
November 27th, 2013, 09:28 AM
The Java SE tutorial covers exceptions in general

http://docs.oracle.com/javase/tutorial/essential/exceptions/

Specifically, it deals with the throws keyword in this section

http://docs.oracle.com/javase/tutorial/essential/exceptions/declaring.html

ofnuts
November 27th, 2013, 04:10 PM
The throws keywords is used when you don't want to handle some exception in the method, but leave its handling to some code higher in the call hierarchy. More or less by using "throws" the implementation of the method passes the hot potato to its caller, which can in turn dodge it by using "throws" itself.