我写的跟老师写的一样,但是总是在报错,是什么原因呢?
package com.xuan;
public class ChainTest{
public static void main(String[] args) {
// TODO Auto-generated method stub
ChainTest ct = new ChainTest();
try{
ct.test2();
}catch(Exception e){
e.printStackTrace();
}
}
public void test1()throws DrunkException{
throw new DrunkException ("喝酒不要开车");
}
public void test2(){
try{
test1();
}catch(DrunkException e){
RuntimeException re = new RuntimeException(e);
throw re;
}
}
}