1、
public static void main(String[] args) { int [] a=new int[2]; System.out.println(a[2]); }
错误提示:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at javastudy.ArrayDemo.main(ArrayDemo.java:17)
错误说明:
ArrayIndexOutOfBoundsException 数据角标越界异常。
因为本数据只有两个元素,输出是a[2]是第3个元素,越界了。
原文:http://www.cnblogs.com/ibelieve618/p/6398829.html