开发者社区> 问答> 正文

java 异常问题 在catch里面throw异常,然后在外面的try里面catch?报错

public class test07 {

public static void main(String... args)  {

try {

try {

throw new aaException("origin");

} catch (aaException e) {

Throwable se = new aaException("new");

se.initCause(e);

throw se;//eclipse这里报错,不知道为什么

}

} catch (Exception t) {

System.out.print(t.getMessage());

}

}

}

展开
收起
爱吃鱼的程序员 2020-06-09 10:34:27 640 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    publicclassExceptionextendsThrowable{,<spanstyle="font-size:13.3333px;">Exception是<spanstyle="font-size:13.3333px;">Throwable的子类,不能代表所有的<spanstyle="font-size:13.3333px;">Throwable。

    2020-06-09 10:34:42
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载