HedonicHedgehog HedonicHedgehog - 3 months ago 18
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)


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