Equivalente en Java de C # Array.GetLength (i)

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

preguntado el 09 de marzo de 12 a las 16:03

3 Respuestas

No, because Java doesn't tener multi-dimensional arrays. It only has jagged arrays, i.e. arrays of arrays.

respondido 09 mar '12, 16:03

No. Java doesn't have multi-dimensional arrays. What it has is arrays of arrays (etc) but each level can be a different size.

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

respondido 09 mar '12, 16:03

So would ints.GetLength(0) be equivalent to int.length then? - adam0101

Yes. and ints[0].length sería 1, ints[1].length es 3 - pedro laurey

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

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

respondido 09 mar '12, 16:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.