public class TestException {
int m1() {
try {
int i = 10, j = 0;
System.out.println("s1");
i = i / j;
return 11;
} catch (Exception e) {
System.out.println("s2");
} finally {
System.out.println("s3");
}
System.out.println("s4");
return 2222;
}
public static void main(String[] args) {
System.out.println(new TestException().m1());
}
}
Run Code Online (Sandbox Code Playgroud)
O/P: -
s1
s2
s3
s4
2222
Run Code Online (Sandbox Code Playgroud)
s3以前为什么s4?
finally在方法返回之前不调用?
我在这里错过了什么?
| 归档时间: |
|
| 查看次数: |
121 次 |
| 最近记录: |