我知道你可以使用 Java 7,multi-catch
但我想知道它的异常顺序是否像以前的 Java 版本一样重要?例如,我输入 Exception 然后SQLException
和IOException
?
try {
// execute code that may throw 1 of the 3 exceptions below.
} catch(Exception | SQLException | IOException e) {
logger.log(e);
}
还是我应该这样做?
try {
// execute code that may throw 1 of the 3 exceptions below.
} catch(SQLException | IOException e) {
logger.log(e);
} catch(Exception e) {
logger.severe(e);
}