加载中...
加载中...
JAVA 自定义异常使用 Exception

JAVA 自定义异常使用 Exception 原创

JAVA 自定义异常使用Exception

复制收展Javapackage com.algorithm.demo;

/**
* @Desc 累行客
* @Author luolei
* @Web http://www.leixingke.com/
* @Date 2020/11/17 15:05
*/
class BaseException extends Exception{}
class MyException extends BaseException {}
public class ExceptionTest1 {
public static void main(String[] args) throws Exception {
try {
try {
throw new MyException();
}
catch (MyException e) {
System.out.println("Caught MyException1");
BaseException newException = (BaseException)e;
throw newException;
}
}
catch (MyException e) {
System.out.println("Caught MyException2");
return;
}
catch (BaseException e) {
System.out.println("Caught BaseException3");
throw e;
}
finally {
System.out.println("finally");
}
}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35


没有更多推荐了 [去首页]
image
文章
376
原创
293
转载
83
翻译
0
访问量
183411
喜欢
73
粉丝
5
码龄
7年
资源
3

文章目录

加载中...
0
0