Java 7.0 has come up with a new feature where it is possible to catch multiple exceptions in a particular catch block. For example
catch (IOException | SQLException ex) {
logger.log(ex);
throw ex;
}
In this case both IOException and SQLException will be caught in the same block.It has to be noted though that the parameter is implicitly final i.e the parameter cannot be assigned to any other Object.
No comments:
Post a Comment