尚硅谷—初级—异常处理(371~383)
作者:互联网
https://www.bilibili.com/video/BV1Kb411W75N?p=371
一.异常概述:
1)介绍:
a:异常概述与异常体系:
b:常见异常:
c:异常处理机制:try catch finally
d:异常处理机制:throws
e:手动抛出异常:throw
f:用户自定义异常:
二.异常概述与异常体系:
三.异常处理机制:
1)try-catch-finally:
try{
-------
} catch (Exception e ) {
-------
}finally {
-------
}
2)throws:
public void tt(int i) throws Exception{
------
}
四.手动抛出异常:
throw new RuntimeException("111");
五.自定义异常:
public class MyException extends RuntimeException {
public MyException() {
}
public MyException(String msg) {
super(msg);
}
}
标签:MyException,-------,catch,finally,383,371,硅谷,异常,public 来源: https://blog.csdn.net/qq_43056248/article/details/116103187