為什么編的是錯誤的呢????
package demo.q;
public class ChainTest {
/*
?* test1()拋出"喝大了“異常
?* test2():調用test1()捕獲"喝大了"異常,并且包裝成運行時異常,繼續拋出
?* main方法中,調用test2()嘗試捕獲test2()方法拋出的異常?
?*/
public static void main(String[] args) {
// TODO Auto-generated method stub
public void test1() throws DrunkException{
throw new? DrunkException("喝酒別開車!")
}
}
}
2019-07-21
你test1方法在主函數入口里面,肯定錯誤的啊,寫法不對。解決方法,將test1()方法寫到主函數外部。