把代码改成这样,就OK了
public class Test {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 10; i++) {
try {
if (i % 3 == 0)
throw new Exception("有异常出现");
System.out.println(i);
} catch (Exception inner) {
i *= 2;
if (i % 3 == 0)
try {
throw new Exception("E1");
} catch (Exception e) {
throw new Exception(e); }
} finally {
}
}
}
} |