Back to Top

Saturday, 28 January 2012

JAVA: Difference between throw & throws

throw is used to throw an exception in a program, explicitly.
Whereas,  throws is included in the method's declaration part, with a list of exceptions that the method can possible throw. It is necessary for all exceptions(except for Error & RuntimeException & their sub-classes).

8 Responses to “ JAVA: Difference between throw & throws ”

Arraylist tutorial example java said...
28 March 2012 at 09:27

throw can also be used in flow control like breaking from switch statement. see 3 difference between throw and throws in java for more details.

Anonymous said...
26 August 2012 at 11:53

Using throws we only provide information related to unhandled exceptions of a method.throws keyword would not perform any kind of actions.
BUT using 'throw' we explicitly raise an exception and throw would not provide any information rather it perform certain action.

Gokul Manoharan said...
18 October 2012 at 20:50

We have lot of differences in between throw and throws...when we are using throws which we can use within that method signature but throw we can use inside the method else SIB using throws keyword along with that we can pass multiple exceptions but using throw keyword we can't pass multiple exception...and here we can produce our own exception like we can call explicit exceptions...but in throws we use only checked Exception.... By Gokul Lara Technologies Bangalore...

aaaaa said...
3 May 2013 at 16:58


Naviya Nair said...
24 October 2016 at 15:02

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

Java Training Institutes in Chennai Java Training in Chennai

jazz said...
21 March 2017 at 16:52

Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post..Interesting post!
Thanks for writing it.What's wrong with this kind of post exactly? It follows your previous guideline for post length as well as clarity.
Cloud Computing Training in Chennai

calfre services said...
28 July 2018 at 17:19

Thanks for sharing this Informative content. Well explained. Got to learn new things from your Blog java training

sumant kumar said...
29 August 2018 at 18:37

I found best article.thank you for sharing useful info.
web programming tutorial

Post a Comment

Popular Posts

Subscribe via Email
Subscribe Java Interview Questions via Email
All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
blog links Web Directory Academics Blogs