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("出错了");
}
}
}
原文地址:https://www.cnblogs.com/zhujialei123/p/9043606.html
时间: 2024-10-07 01:54:45