These days, I have been trying to learn java, But I am confused about Throws exceptions. is this statement correct?: Throws in method signature causes an exception (or some exceptions) throw to another method that is calling this method. and caller method has try/catch to handle thrown exception.
Thanks in advance. Farrohk
Neither statement is correct.
Throws in method signature causes an exception (or some exceptions) throw to another method that is calling this method
Declaring that a method throws an exception just indicates that it might throw the exception, not that it does.
and caller method has try/catch to handle thrown exception.
The caller can declare that it throws the same exception, rather than try/catching, so the exception is propagated to that method's caller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With