java - How to use final in a multi-catch statement? -
how give final modifier exception when catching multiple type of exceptions in single catch block in java
you don't need mark every exception final. first one.
try { } catch(final illegalargumentexception | arrayindexoutofboundsexception e) { e = new runtimeexception();//this not allowed e final } that being said, don't need mark e final cannot reassgined in catch block either way when using multi-catch statement.
here's relevant section of jls
an exception parameter of multi-catch clause implicitly declared final if not explicitly declared final.
it compile-time error if exception parameter implicitly or explicitly declared final assigned within body of catch clause.
Comments
Post a Comment