Why is the argument final in a catch catch statement

In the case of a single statement catch

to handle multiple exceptions, why is the argument implicit final

?

catch (IOException|SQLException ex) {
    logger.log(ex);
    throw ex;
}

      

In this code, ex final

. Why is this so?

+3


source to share


1 answer


Otherwise, you might be tempted to write something like ex = new IOException();

, but since the type is not really IOException

or SQLException

, it will violate type safety in a strange way.



+3


source







All Articles