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