Java小笔记

  • catch多种异常
        try {
            int a = 1 / 0;// 除以0
        } catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
            // 多个异常见用 | 隔开
            // 多个异常必须是平级关系
            System.out.println("发生了ArithmeticException 或者 ArrayIndexOutOfBoundsException 异常");
        }
posted @ 2021-09-02 15:38  cyhui  阅读(23)  评论(0)    收藏  举报