runtimeException也是能够捕获的

如题,
运行结果: 

bbb
abcdef

@Test
public void testRuntimeException() {
    int a = 0;

try {
aaa333();
} catch (Exception ex) {
System.out.println("bbb");
}

System.out.print("abcdef");
}

private void aaa333() {
int a = 0;

try {
int b = 32 / a;
} catch (Exception ex) {
throw new RuntimeException("error;");
}

}

posted @ 2018-08-16 15:55  星朝  阅读(3114)  评论(0)    收藏  举报