In the docs for multiple try-catch there is a statement.
If a catch block handles more than one exception type, then the catch parameter is implicitly final. In this example, the catch parameter ex is final and therefore you cannot assign any values to it within the catch block
But I don't get it. What do they mean by cannot assign any values? I can all every method of exception object as far as I remember. What assignment they are talking about?
If you use a multi-catch then you cannot change the Exception reference;
try {
} catch (IOException|SQLException ex) {
ex = null; // <-- NOT LEGAL, the ex is final.
}
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