一、异常
就是在程序的运行过程中所发生的不正常的事件,它会中断正在运行1的程序。
Java异常处理五个关键字:try,catch,finally,throw,throws
public class test01 {
public static void main(String[] args) {
try {
int m = 1;
int n = 0;
System.out.println(m / n);
}catch(Exception ex) {
System.out.println("程序错误");
}
}
}
finally 程序无论是否出现异常,这个逻辑都必须执行
throws方法声明处,交给调用处,try-catch处理