异常输出顺序不同...
环境: 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()
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()
...全文
相关推荐
C++实现顺序表-已运行成功
- `const int MaxSize = 10;`:定义了一个常量`MaxSize`用于表示顺序表的最大容量。- `template<class T>`:使用模板类,允许创建不同类型的顺序表实例。
线性表的顺序存储结构与操作
**遍历输出操作**:输出顺序表中的所有元素。6. **获取长度操作**:返回顺序表中当前元素的数量。#### 三、代码实现解析1.
java异常处理试题及答案.doc
**示例1(第五道选择题)**: - 该示例中包含了两个可能引发异常的操作:除以零和访问数组越界。 - 根据题目描述,程序将在运行时根据输入参数的不同而产生不同的输出结果。
Python中顺序表的实现简单代码分享
在Python中,顺序表是一种基本的数据结构,它按照元素的添加顺序存储数据,通常使用数组实现。本篇文章将深入探讨Python中顺序表的实现,包括其核心代码、操作方法以及如何处理不同情况。
详解Django中间件执行顺序
在Django框架中,中间件是介于Web请求和响应处理过程中的一个组件,它允许开发者在Django处理视图前后的不同阶段,插入自己的代码对输入或输出进行干预。


Java SE
