weixin_慕慕7498354
2022-04-26 15:42
package com.H.test;
public class ChainTest {
public static void main(String[] args) {
ChainTest ct=new ChainTest();
try {
ct.test2();
}catch (Exception e){
e.printStackTrace();
}
}
public void test1()throws DrunkException{
throw new RuntimeException("喝酒别开车!");
}
public void test2(){
try {
test1();
} catch (DrunkException e) {
RuntimeException newExc=new RuntimeException("司机一滴酒");
newExc.initCause(e);
throw newExc;
}
}
}
public void test1()throws DrunkException{
throw new DrunkException("喝酒别开车!");
}Java入门第三季
409776 学习 · 4546 问题
相似问题