class OneException extends Exception {
public OneException(String s){
super(s);
}
}
class TowException extends Exception{
public TowException(String s){
super(s);
}
}
public class RethrowNew{
public static void f()throws OneException{
System.out.println("originationg the exception in f()");
throw new OneException("thrown from f()");
}
public static void main(String[] agrs)throws Throwable{
try{
f();
}
catch(OneException e){
System.err.println("caught in main,e.printstacktrace()");
e.printStackTrace(System.err);
throw e;
}
}
}
在main()的catch()中我抛出异常e:throw e;但不知这个异常如何被捕获,哪位
高手可以帮小弟解决一下啊。
上述程序的运行结果如下:
originationg the exception in f()
caught in main,e.printstacktrace()
OneException: thrown from f()
at RethrowNew.f(RethrowNew.java:15)
at RethrowNew.main(RethrowNew.java:19)
Exception in thread "main" OneException: thrown from f()//不知道这段信息如何出来
at RethrowNew.f(RethrowNew.java:15)
at RethrowNew.main(RethrowNew.java:19)