开发者

2D Array Question Java

If I开发者_如何学C have a 2D array arr[rows][columns], how could I use arr.length to find size for rows and columns individually?


arr.length 

will be the number of rows

arr[x].length

will be the number of columns in row x.


You can find the number of rows as:

arr.length

In Java all the rows need not have same number of elements. You can find the number of elements in the row i as:

arr[i].length


Rows - arr.length
Columns -arr[rowNumber].length //Each row can have different number of elements
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜