1

I've created a multidimensional array and populated it:

int[][] multiArray = { {1,2,3} , {4,5,6,7} };

and if I do the following:

System.out.println(multiArray.length);

I'll get the value 2, which is the number of columns in this matrix.

But what is the syntax I have to use in order to get the length of a certain column?

I know how to address a specific item in order to get it or change it (for example, multiArray[0][2] would let me address value = 3). Just need to know how to address the length of a specific column.

4

2 回答 2

4

您可以使用multiArray[i].length来获取第 i 列的长度。

于 2013-05-27T19:05:02.287 回答
2

您可以通过调用它来获取特定行的长度.length

System.out.println(multiArray[i].length);
于 2013-05-27T19:05:14.913 回答