在正常的try-catch-finally中,像这样,
try {
throw new ExceptionA();
} finally {
throw new ExceptionB();
}
Run Code Online (Sandbox Code Playgroud)
ExceptionA在Exception B之前抛出.ExceptionA将被禁止.
但是在try-with-resource中,像这样,
try ( // declare resource that throw ExceptionA in close method ) {
throw new ExceptionB();
}
Run Code Online (Sandbox Code Playgroud)
ExceptionA在ExceptionB之后抛出.ExceptionA将被禁止.
为什么他们有不同的抑制异常的命令?