public static void main(String args[ ])
{
int a[3];
try{ a[3]=10; . . .//其他语句 }
catch(Exception ee)
{ System.out.println(ee.toString()); }
catch( ArrayIndexOutOfBoundsException e)
{ System.out.println(e.toString()); }
}
你异常捕获的方式写错了。是最小的异常放上面处理,最大的放下面哦。
修改为如下:
public static void main(String args[ ])
{
int a[3];
try{ a[3]=10; . . .//其他语句 }
catch(ArrayIndexOutOfBoundsException ee)
{ System.out.println(ee.toString()); }
catch(Exception e)
{ System.out.println(e.toString()); }
}
注意,异常只能从小捕获到大即最里层的捕获不能大于最外层的捕获,Exception类是运行时异常类的父类,ArrayIndexOutOfBoundsException是它的子类,所以它们的顺序调换一下即可,如有帮助,望采纳!!