public class Test {
public static String output = "";
public static void foo(int i) {
try {
if (i == 1)
throw new Exception();
output += "1";
} catch (Exception e) {
output += "2";
return;
} finally {
output += "3";
}
output += "4";
}
public static void main(String[] args) {
foo(0);
System.out.println(output);
foo(1);
System.out.println(output);
}
}
问输出结果是什么?
java异常中一个有趣的例子
最新推荐文章于 2021-12-24 21:52:50 发布