public class TestDemo09
{
public static void main(String[] args){
try{
int a=1/0;
int[] b={1,2};
b[4]=4;
}
catch(ArithmeticException e){
System.out.print("rrr");
}
catch(ArrayIndexOutOfBoundsException e){
System.out.print("vvv");
}finally{
System.out.print("sss");
}}
}
//大家帮帮忙异常关系

解决方案 »

  1.   

    首先你这个方法肯定数组越界。
    而且也会抛出ArithmeticException异常
    只不过有个先后问题,比如你先抛出ArithmeticException异常了,那么下一步就直接跳fianlly了。
    而没有运行
    catch(ArrayIndexOutOfBoundsException e){
    System.out.print("vvv");
    }这个
      

  2.   

    ArrayIndexOutOfBoundsException和ArithmeticException好像没有什么关系,为什么会存在先后的问题?