package itheima_05;
public class Demo01 {
public static void main(String[] args) {
int a=1;
int b=0;
//如果捕获多个异常,从小到大
try { //监控区域
System.out.println(a/b);
} catch (Error e){ //catch (想要捕获的异常类型) 捕获异常
System.out.println("Error");
}
catch (Exception e) {
System.out.println("Exception");
}
catch (Throwable t){
System.out.println("Throwable");
}
finally { //处理善后工作
System.out.println("finally");
}
}
}

浙公网安备 33010602011771号