public class CheckProg {
public int math(int i) {
try {
int result = i / 0;
// throw new IOException("in here");
} catch (Exception e) {
return 10;
} finally {
return 11;
}
}
public static void main(String[] args) {
CheckProg c1 = new CheckProg();
int res = c1.math(10);
System.out.println("Output :" + res);
}
Run Code Online (Sandbox Code Playgroud)
问:如果我运行上面的代码,我得到的结果为输出:11
为什么?不应该在catch块之前捕获异常并返回吗?