使用此代码:
class SimpleException extends Exception {}
public class SimpleExceptionDemo {
public void f() throws SimpleException {
System.out.println("Throw SimpleException from f()");
throw new SimpleException();
}
public static void main(String[] args) {
SimpleExceptionDemo sed = new SimpleExceptionDemo();
try {
sed.f();
} catch(SimpleException e) {
System.err.println("Caught it!");
}
}
}
在某些情况下,我有这个输出:
Caught it!
Throw SimpleException from f()
你知道为什么在“caught it”之后会打印“Throw SimpleException from f()”吗?