Java Length of One Dimension From A Multidimensional Array

So you know how you can do array.length, I have an array with [][][][], and what do I do to find the length of one section?

So let's say

Code:

`int array[][] = {`

{5, 5, 5, 5},

{4, 4, 4, 4},

{3, 3, 3, 3}

}

How do I find out the length of the {5, 5, 5, 5} which is 4. Because there are 4 place-holders.

Is there a way??

Re: Java Length of One Dimension From A Multidimensional Array

Multidimensional arrays in Java are nothing more than arrays referring to arrays referring to arrays. So you can actually reference a "2D" array as

a "1D" array:

Code:

`int[][] a; // allocated and initialized somewhere else.`

for (int j = 0; j < a.length; j++) {

System.out.println(a[j].length);

}

Regards,

Jim

Re: Java Length of One Dimension From A Multidimensional Array

Your two dimensional array is an array of arrays and you could do something like array[1].length

With kind regards,

Konrad

Re: Java Length of One Dimension From A Multidimensional Array