/**
* Date:2019/8/8
* Author:zkh
* DESC:数组越界异常:访问不存在的索引,辉造成数组越界异常
*/
public class ArrayIndexOutOfBoundsExceptionDemo {
public static void main(String[] args) {
int[] arr = {3, 5};
System.out.println(arr[2]);
}
}
解决方法:
本文通过一个示例详细解析了数组越界异常的概念,当尝试访问数组中不存在的索引时,程序会抛出ArrayIndexOutOfBoundsException。文章提供了一个简单的Java代码示例,演示了如何触发这一异常,并探讨了解决方案。
/**
* Date:2019/8/8
* Author:zkh
* DESC:数组越界异常:访问不存在的索引,辉造成数组越界异常
*/
public class ArrayIndexOutOfBoundsExceptionDemo {
public static void main(String[] args) {
int[] arr = {3, 5};
System.out.println(arr[2]);
}
}
解决方法:
321
670
2094

被折叠的 条评论
为什么被折叠?