Eclipse没有显示错误,却运行不了
(class 1:)
package com.imooc.test;
public class DrunkException extends Exception {
public DrunkException(){
}
public DrunkException(String message){
super(message);
}
}
(Class 2:)
package com.imooc.test;
public class ChainTest {
/**
* test1():抛出“喝大了”异常
* test2():尝试捕获“喝大了”异常,并且包装成运行时异常,继续抛出
* main方法中,调用test2(),尝试捕获test2()方法抛出的异常
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ChainTest ab=new ChainTest();
//use the try-catch to surround the test2()
try {
ab.test2();
}catch(Exception e){
e.printStackTrace();
}
}
public void test1() throws DrunkException{
throw new DrunkException("开车别喝酒");
}
public void test2() {
try {
test1();
} catch (DrunkException e) {
//新建一个RuntimeException的方法,并将捕获的异常传递给它
RuntimeException newExc=
new RuntimeException("司机一滴酒,亲人两行泪");
//newExc.initCause(e);
throw newExc;
}
}
}
运行结果:
请问这是什么问题呢???