下面是一個正在傳播異常處理機制的問題,期望的輸出是Exception.Can任何人都可以解釋爲什麼輸出是Exception,謝謝提前。核心-java異常處理
Class Question {
public void m1() throws Exception {
try {
m2();
} finally {
m3();
}
}
public void m2() throws RuntimeException {
throw new RuntimeException();
}
public void m3() throws Exception {
throw new Exception();
}
public static void main(String[] args) throws Exception {
Question q = new Question();
try {
q.m1();
} catch (RuntimeException re) {
System.out.println("RuntimeException");
} catch (Exception e) {
System.out.println("Exception");
}
}
因爲m1'拋出Exception' – Ravi
如果在finally塊中我調用m2()方法whats輸出? –
如果在finally塊中我調用m2()方法whats的輸出? RuntimeException – developer