我寫的跟老師寫的一樣,但是總是在報錯,是什么原因呢?
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;
}
}
}
2016-02-10
報的什么錯,肯定會報的啊,就是要報出異常信息啊~~~~
2016-02-05
最后的re是哪里來的?
2015-12-24
恩,我試著繼承了這個類,但是還是不行,就是自定義類。。。
2015-12-20
你的DrunkException這個類應該沒有繼承自Exception類吧,java中可沒有這個類