异常输出顺序不同...

fdm_sea fdm_sea 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
环境: eclipse2.1.3
jre: 1.4.2_05
代码:
public class TestException {
static void g() throws IOException {
throw new IOException("throw from g()");
}
public void h() throws IOException {
throw new IOException("throw from h()");
}

public static void main(String[] args) {
System.out.println("Start main()!!!");
try {
g(); // 1
// new TestException().h(); // 2
}
catch (IOException e) {
System.err.println(e);
}
System.out.println("End main()");
}
}
请教,为什么两次的输出顺序不同??
注释掉2,结果是:
java.io.IOException: throw from g()
Start main()!!!
End main()

注释掉1,结果是:
Start main()!!!
End main()
java.io.IOException: throw from h()
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
fdm_sea
Java SE 62,621 成员 307,251 内容