1个异常的问题
public class Rethrowing {
public static void f() throws Exception {
System.out.println("originating the exception in f()");
throw new Exception();
}
public static void g() throws Exception
try {
f();
} catch(Exception e) {
System.err.println("Inside g(),e.printStackTrace()");
e.printStackTrace();
throw e; // 17
// throw e.fillInStackTrace(); // 18
}
}
public static void
main(String[] args) {
try {
g();
} catch(Exception e) {
System.err.println(
"Caught in main, e.printStackTrace()");
e.printStackTrace();
}
}
} ///:~
我发现当我把public static void g() throws Exception改成public static void g() throws Throwable
那么下面的MAIN 也要加throws Throwable
我想知道为什么。