异常处理try...catch...catch

package com.day16.Exception;

public class ExceptionTwo {

  public static void main(String[] args) {
    int a=10;
    int b=0;
    int[] arr= {1,2,3,4,5};
    try {
      System.out.println(a/b);
      System.out.println(arr[10]);
    } catch (ArithmeticException e) {
      System.out.println("除数不能为0");
    } catch (ArrayIndexOutOfBoundsException e) {
      System.out.println("数组索引越界了");
    } catch (Exception e) {
      System.out.println("出错了");
    }
  }

}

posted @ 2018-05-15 22:58  简简单单zjl  阅读(150)  评论(0)    收藏  举报