1
assylias很好地解釋了關於final rethrow。 我加了最後的method3
。java7中的精確rethrow異常
public void method4() throws IOException {
try {
throw new IOException("1");
} catch (final Exception e) {
e = new IOException("2"); //does not compile
throw e; //does not compile
}
}
我將我的編譯器設置爲1.7。 有兩個編譯錯誤:
final exception can neither be reassigned nor throw precise exception.
所以,明確最終異常僅用於防止修改?