相关疑难解决方法(0)

迭代遍历数组的所有元素时出现ArrayIndexOutOfBoundsException

如何处理这个异常"ArrayIndexOutOfBoundsException"我的代码:我创建一个64长度的数组然后我初始化每个索引然后我打印索引,以确保我正在填充所有索引,但它打印到63然后给出异常!任何的想法

    public static void main(String [] arg) {
    int [] a=new int [64];
    for(int i=1;i<=a.length;i++){
        a[i]=i;
        System.out.println(i);
    }

}
Run Code Online (Sandbox Code Playgroud)

java arrays

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

java ×1