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");
        }

    }
}

 

posted on 2022-01-04 12:56  凛至  阅读(27)  评论(0)    收藏  举报