哪为兄台能帮我解释一下
package test;
import java.sql.*;
public class Test {
public Test() {
}
public static void main(String[] args) {
Untitled6 untitled61 = new Untitled6();
try{
untitled61.test1();
}catch(Exception e) {
System.out.println("In main()");
e.printStackTrace();
}
}
public void test1() throws Exception {
ResultSet rs = null;
Statement statement= null;
Connection connection = null;
try{
rs.close();
}catch (Exception e){
//e.printStackTrace();
System.out.println("In catch");
throw e;
}finally{
System.out.println("In finally");
throw new java.io.IOException("IOException");
}
}
}
上面是我做的一个测试,输出的结果为:
java.io.IOException: IOException
at test.Untitled6.test1(Untitled6.java:30)
at test.Untitled6.main(Untitled6.java:12)
In catch
In finally
In main()
我很纳闷,为什么结果不是:
In catch
In finally
In main()
java.io.IOException: IOException
at test.Untitled6.test1(Untitled6.java:30)
at test.Untitled6.main(Untitled6.java:12)
哪位大哥能给小弟解释一下??