原因:下标超出了数组长度
public static void main(String[] args) {
//数组越界异常
//ArrayIndexOutOfBoundsException
String[]names={"五仁月饼","香辣牛肉月饼","金嗓子月饼","韭菜月饼"};
System.out.println(names[4]);
}
输出结果:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:4
ata3.main(a3.java:5) |
|