HedonicHedgehog HedonicHedgehog - 1 year ago 63
Java Question

Finding length of all arrays multidimensional array, Java

I would like to use a multidimensional array to store a grid of data. However, I have not found a simple way to find the length of the 2nd part of the array. For example:

boolean[][] array = new boolean[3][5];

will only output 3.

Is there another simple command to find the length of the second array? (i.e. output 5 in the same manner)

Answer Source

Try using array[0].length, this will give the dimension you're looking for (since your array is not jagged).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download