我想问一个已经磨碎 ja 的代码问题,我有以下代码,我正在通过一个 10x5 数组来填充数字 1,到 49 来填充原语,负责制作票证的函数给了我非常罕见的错误。Index On Bound 理论上该功能不会被排除在外,但如果有人可以打我,我不知道该怎么办。
// It is this part that gives me an error, I have a fly
int ,c=0;
int m[][]= new int[10][5];
for (int i=0;i<m.length;i++) {
for (int x=0;x<m.length;x++,i++) {
m[x][i]=c;
}
}
// This part of code I only have to check if the data output
// does them correctly
for(int i=0;i<m[0].length;i++) {
for(int x=0;x<m.length;x++) {
System.out.print(" "+m[i][x]+" ");
}
System.out.println(" ");
}
}
El error que me da es siguiente:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
at provas/provas.main.main(main.java:11)