Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java equivalent of C# Array.GetLength(i)

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

like image 409
adam0101 Avatar asked Dec 06 '22 15:12

adam0101


2 Answers

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

like image 102
Jon Skeet Avatar answered Dec 18 '22 06:12

Jon Skeet


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} };
like image 26
Peter Lawrey Avatar answered Dec 18 '22 07:12

Peter Lawrey