package cn.tx.exception;
public class ExceptionDemo6 {
public static void main(String[] args) {
int a = 10;
int b = 0;
//try{}catch(){}的快捷键是Shift+Alt+Z
divide(a,b);
}
public static int divide(int a, int b){
int c = 0;
try {
int[] arr = new int[10];
System.out.println(arr[9]);
c = a/b;
} catch (Exception e) {
if(e instanceof ArithmeticException){
System.out.println("处理数学异常");
}else{
System.out.println("数组越界异常");
}
}
return c;
}
}