Monday, January 14, 2013

What's the difference between throw, throwable & throws?



throw and throws are java keywords and Throwable is a super class for errors and exceptions.
Only the objects of the Throwable can be thrown by the “throws” or “throw” statement.

throws :
used on the method to specify than an exception(s) can be thrown. The throws clause tells the complier that this particular exception would be handled by the calling method.

throw :
it is a statement to throw the exception when certain condition is failed or other logic had returned exception. This can be used in any part of code where you feel a specific exception needs to be thrown to the calling method

http://www.linkedin.com/groups/Whats-difference-between-throw-throwable-70526.S.200485518?view=&srchtype=discussedNews&gid=70526&item=200485518&type=member&trk=eml-anet_dig-b_pd-ttl-cn&ut=17ZTwoVDpUpBA1