C # java equivalent of Array.GetLength (i)

Does Java have a function that gets the length of a specified dimension of a multidimensional array?

+4
source share
3 answers

Not. Java does not have multidimensional arrays. It has arrays of arrays (etc.), but each level can be of a different size.

int[][] ints = { { 1 }, {1,2,3}, {5,6} }; 
+6
source

No, because Java does not have multidimensional arrays. It has only jagged arrays, i.e. Arrays of arrays.

+7
source

Like the others. Java does not have true multidimensional arrays, but instead has arrays of arrays. To get the length of a specific array, you just need to get a member variable of length for that array:

 int[][] ints = { { 1 }, {1,2,3}, {5,6} }; ints[0].length == 1 ints[1].length == 3 
+2
source

Source: https://habr.com/ru/post/1400607/


All Articles