What is meant by the throws clause?Where & how is it used?
salmanrauf
0
Newbie Poster
Recommended Answers
Jump to PostGreetings,
In Java, all methods use the throw statement to throw an exception. The throw statement requires a single argument: a throwable object. In the Java system, throwable objects are instances of any subclass of the Throwable class.
If you attempt to throw an object that …
Jump to Postthe Throws clause is a way to prepare your method in case it creates an exception.
:)Not exactly. It's more a way to warn other classes that the method they're calling might emit an exception that they'll have to handle. It's used to delegate responsibility for error conditions. For …
Jump to Posti think that using the try catch finall block is more efficient than using the throws
clause..
:)It's nothing to do with "efficiency". If your method can sensibly handle the Execption then it should catch it and handle it. If it can't sensibly handle it it should throw it …
All 11 Replies
Stack Overflow
8
Junior Poster
llianne
0
Newbie Poster
pbl
22
Junior Poster
seanbp
4
Junior Poster
jon.kiparsky
326
Posting Virtuoso

vjcagay
jon.kiparsky
326
Posting Virtuoso
3vilwyatt
0
Newbie Poster
lisaroy1
0
Light Poster

vjcagay
JamesCherrill
4,667
Most Valuable Poster
Team Colleague
Featured 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.