import java.util.Scanner;
public class arrays {
public static void main(String[] args) {
int i;
int [][] m1 = new int[2][3];
int j;
Scanner sc = new Scanner(System.in);
System.out.println(m1.length);
System.out.println(m1[0].length);
for(i = 0; i < m1.length; i++){
for(j = 0; i < m1[0].length; j++) {
m1[i][j] = sc.nextInt();
}
}
sc.close();
}
}
我无法理解为什么会发生此错误。m1.length 和 m1[0].length 打印正确的行和列长度。我给出了以下输入:
1
2
3
4
然后发生错误