【发布时间】:2018-09-25 21:15:13
【问题描述】:
我正在准备OCA 考试,在解决有关Java 异常的主题时发现了一个冲突点。这是引起我困惑的代码:
public class StringOps {
public static void main(String[] args) {
System.out.print("a");
try {
System.out.print("b");
throw new IllegalArgumentException();
} catch (IllegalArgumentException e) {
System.out.print("c");
throw new RuntimeException("1");
} catch (RuntimeException e) {
System.out.print("d");
throw new RuntimeException("2");
} finally {
System.out.print("e");
throw new RuntimeException("3");
}
}
}
此代码输出:
a-> b -> c -> e。
但我不明白为什么?我以为它会输出:
a-> b -> c -> d -> e。
任何帮助将不胜感激!
【问题讨论】: