what is the difference between throw and throws clause in java????
mmm.....i no that all methods in java use the throw statement to throw an exception and the throw statement requires a single argument : a throwable object....
but plz can any1 tell me the function of the throws clause?????
shakeelahmed22 0 Newbie Poster
Recommended Answers
Jump to PostThe answer is simple English grammar:
A method throws an Exception:
public void method(int i) throws Exception { }
The method throws an Exception when you call it
But you throw an Exception:if (i<0) throw new Exception();
If 'i' is …
All 4 Replies
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
shakeelahmed22 0 Newbie Poster
shakeelahmed22 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.