[英]Printing two dimensional array in Java
I'm trying to figure out what's wrong with my code for printing the two dimensional array我试图弄清楚我打印二维数组的代码有什么问题
int[][] container = new int [3][6];
for (int i = 0; i <= 3; i++) {
for (int j = 0; j <== 6; j++) {
System.out.print(contianer[i][j] + " ");
}
}
System.out.println();
<==
is not an operator. <==
不是运算符。length - 1
数组从 0 开始到length - 1
for
您在for
中的变量中有错字System.out.println();
must be executed inside the first for
not outside.必须先在内部执行for
不是在外部执行。int[][] container = new int [3][6];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 6; j++) {
System.out.print(container[i][j] + " ");
}
System.out.println();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.