异常

public class Demo01 {
public static void main(String[] args) {
int a=1;
int b=0;
try { //try监控区域
System.out.println(a/b);
}catch (ArithmeticException e){
System.out.println("程序出现异常,变量b不能为0");
}finally { //处理善后工作
System.out.println("finally");
}

//可以不用finally 在IO中可以用于资源关闭

//快捷键 ctrl+alt+t
}
}

原文地址:https://www.cnblogs.com/dadabai/p/12361397.html