请问test2() throw 的RuntimeException 为什么不需要test2() throws Exception 声明抛出异常?
请问test2() throw 的RuntimeException 为什么不需要test2() throws Exception 声明抛出异常?
public void test1() throws DrunkException{
throw new DrunkException("喝车别开酒!");
}
public void test2(){
try {
test1();
} catch (DrunkException e) {
// TODO Auto-generated catch block
RuntimeException newExc =
new RuntimeException(e);
// newExc.initCause(e);
throw newExc;
}
}