+ 4
JAVA. Can we have multiple catch blocks after try block?
Can we have multiple catch blocks after try block? Also, does coding a catch block for a parent exception type before the catch block of one of its subclasses causes a compilation error? Thank you for help!
3 Antworten
+ 3
Yes you can.
After some testing, it seems you can't catch parent exception before child exception and it will give compilation error. You can do the reverse.
https://code.sololearn.com/c3dP00YdWptV/?ref=app
+ 2
Yes, you can have multiple catch blocks, and for the second one, I'm pretty sure it doesn't.
+ 2
thank you very much, guys! I already figured out