posted 24 years ago
Hi,
As I understand, the throws clause is used in the method
declaration indicating that the method being created might throw an exception(which is being declared) and the application/program using this method should be able to handle it.
Now, my questions are:
1. Since we always code try and catch for an exception we want
to handle inside the method being created, why do we have
to mention throws in the method/class declaration and let
other methods/classes handle the exception?
2. If the above case is true, why do we need to have throws
clause at all, if we are able to handle all the exceptions
using try and catch?
Am I making sense here? Please clarify my doubts.
Thanks