frece
首先 你数组定义错了,应该用大括号代码: public static void main(String[] args) {
// int[][] iArr = new int[][] { { 1, 2 }, { 3, 4, 5, 6 }, { 7, 8, 9 }, { 10 } };
int[][] iArr = { { 1, 2 }, { 3, 4, 5, 6 }, { 7, 8, 9 }, { 10 } };
for (int i = 0; i < iArr.length; i++) {
System.out.println("iArr[" + i + "].length = " + iArr[i].length);
}
}结果:iArr[0].length = 2iArr[1].length = 4iArr[2].length = 3iArr[3].length = 1