This will give you the length of the array at index i

pathList[i].length

It's important to note that unlike C or C++, the length of the elements of a two-dimensional array in Java need not be equal. For example, when pathList is instantiated equal to new int[6][], it can hold 6 int [] instances, each of which can be a different length.


So when you create arrays the way you've shown in your question, you may as well do

 pathList[0].length

since you know that they all have the same length. In the other cases, you need to define, specific to your application exactly what the length of the second dimension means - it might be the maximum of the lengths all the elements, or perhaps the minimum. In most cases, you'll need to iterate over all elements and read their lengths to make a decision:

for(int i = 0; i < pathList.length; i++)
{
    int currLen = pathList[i].length;
}
Answer from no.good.at.coding on Stack Overflow
Discussions

Finding the size of multi dimensional array?
Hi guys, In most of my Arduino program I will always try to implement array. Array had help me to minimise my code substantially all this while. I notice that I have always been using array like the example below: cons… More on forum.arduino.cc
🌐 forum.arduino.cc
8
0
July 4, 2016
Multidimensional Array Length - JavaScript
Hi. Is there any function or property for finding out the size of the first (or for that matter any) dimension of a multidimensional array? EDIT: There seems to be no such functionality, I found a solution that does not require it. If anyone is reading this for the same reason; it needs to ... More on sitepoint.com
🌐 sitepoint.com
0
July 9, 2010
java - Getting the length of two-dimensional array - Stack Overflow
You may need to indicate specifically, how you get the length of an inner array. And also, in general case it is advised to calculate length of current row column < tab[row].length as in Java multidimensional arrays are jagged, and the length of each row may vary. More on stackoverflow.com
🌐 stackoverflow.com
Javascript multidimensional array length problem - Stack Overflow
JavaScript multidimensional array length always returning 0, how can I solve this problem? More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reactgo
reactgo.com › home › how to get the length of a multidimensional array in c#
How to get the length of a multidimensional array in C# | Reactgo
August 26, 2023 - To get the length of a multidimensional (row/column) array, we can use the Array.GetLength() method in C#.
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Finding the size of multi dimensional array? - Programming - Arduino Forum
July 4, 2016 - Hi guys, In most of my Arduino program I will always try to implement array. Array had help me to minimise my code substantially all this while. I notice that I have always been using array like the example below: const uint8_t switchPin [] = { 3, 4, 5, 6, 7, 8, 9}; const uint8_t numOfSwitch = sizeof ( switchPin ) / sizeof ( uint8_t ); anyway I always wanted to know do we get a multi dimensional array index? such example const uint8_t RGBCPin [][] = { ( 2, 3, 4, 5), ( 5, 3, 4, 2), ...
🌐
Coding Rooms
codingrooms.com › blog › 2d-array-length-java
https://www.codingrooms.com/blog/2d-array-length-java
We use arrayname.length to determine the number of rows in a 2D array because the length of a 2D array is equal to the number of rows it has.
🌐
SitePoint
sitepoint.com › javascript
Multidimensional Array Length - JavaScript
July 9, 2010 - Hi. Is there any function or property for finding out the size of the first (or for that matter any) dimension of a multidimensional array? EDIT: There seems to be no such functionality, I found a solution that does not require it. If anyone is reading this for the same reason; it needs to be scripted.
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.array.length
Array.Length Property (System) | Microsoft Learn
using System; public class Example { public static void Main() { // Declare a single-dimensional string array String[] array1d = { "zero", "one", "two", "three" }; ShowArrayInfo(array1d); // Declare a two-dimensional string array String[,] array2d = { { "zero", "0" }, { "one", "1" }, { "two", "2" }, { "three", "3"}, { "four", "4" }, { "five", "5" } }; ShowArrayInfo(array2d); // Declare a three-dimensional integer array int[, ,] array3d = new int[,,] { { { 1, 2, 3 }, { 4, 5, 6 } }, { { 7, 8, 9 }, { 10, 11, 12 } } }; ShowArrayInfo(array3d); } private static void ShowArrayInfo(Array arr) { Console.WriteLine("Length of Array: {0,3}", arr.Length); Console.WriteLine("Number of Dimensions: {0,3}", arr.Rank); // For multidimensional arrays, show number of elements in each dimension.
🌐
Pluralsight
pluralsight.com › blog › tech guides & tutorials
Obtaining The Length Of Single And Multiple Dimensional Arrays In C# | Pluralsight
October 15, 2018 - Now that we know that we cannot get the length of an individual dimension in a multi-dimension array using Length, how do we actually obtain the length? Fortunately for us, .NET provides a useful method called GetLength that accepts the dimension that we want to retrieve. Dimensions are zero based so getting the first dimension uses 0 and the second dimension uses 1. ... using System; namespace Pluralsight.ObtainingArrayLength.MultiDimensions { class Program { static void Main(string[] args) { int[,] myIntegers = new int[20, 30]; int firstDimension = myIntegers.GetLength(0); int secondDimension = myIntegers.GetLength(1); Console.WriteLine($"The total length is {firstDimension}x{secondDimension}"); } } }
🌐
Coderanch
coderanch.com › t › 399717 › java › multidimensional-array-length
multidimensional array length (Beginning Java forum at Coderanch)
data[x][y] I found some info on the net saying if I want to get the first dimension's length I do: data[x].length() However, when I compile I get: cannot resolve symbol method length() Above this part of the code I have a length method that is working fine on the same array, however I am using the following format:
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › csharp › language-reference › builtin-types › arrays
The array reference type - C# reference | Microsoft Learn
Two arrays have two dimensions. Two arrays have three dimensions. The first two declarations declare the length of each dimension, but don't initialize the values of the array. The second two declarations use an initializer to set the values of each element in the multidimensional array.
🌐
Engineering LibreTexts
eng.libretexts.org › campus bookshelves › delta college › c++ programming i (mcclanahan) › 9: introduction to arrays
9.5: Multidimensional Arrays - Engineering LibreTexts
May 4, 2025 - As with the tewo dimensional arrays, it is allowable to simply initialize a series of values that equals the length of the array.
🌐
StudySmarter
studysmarter.co.uk › java multidimensional arrays
Java Multidimensional Arrays: Definition, Creation
A Java Multidimensional Array's structure is not necessarily symmetrical, meaning that each row can have a different length.
🌐
W3Schools
w3schools.com › java › java_arrays_multi.asp
Java Multi-Dimensional Arrays
Note: Notice how rows can have different lengths - In this example, the second row has more elements than the first, and that's perfectly valid in Java.
🌐
Delft Stack
delftstack.com › home › howto › csharp › csharp 2d array length
How to Get Length of a 2D Array in C# | Delft Stack
March 11, 2025 - Another method to determine the dimensions of a 2D array is by using the Array.GetUpperBound() method. This method returns the highest index of a specified dimension, which can then be used to calculate the length by adding one.
🌐
Programiz
programiz.com › java-programming › multidimensional-array
Java Multidimensional Array (2d and 3d Array)
In the above example, we are creating a multidimensional array named a. Since each component of a multidimensional array is also an array (a[0], a[1] and a[2] are also arrays). Here, we are using the length attribute to calculate the length of each row.
🌐
MathWorks
mathworks.com › matlab › language fundamentals › matrices and arrays
size - Array size - MATLAB
However, if A is a string scalar, size returns [1 1] because it is a single element of a string array. For example, compare the output of size for a character vector and string: ... Dimension lengths, returned as a nonnegative integer scalar when dim is a positive integer scalar, a row vector of nonnegative integer scalars when dim is a vector of positive integers, or a 1-by-0 empty array when dim is an empty array.
🌐
Sololearn
sololearn.com › en › Discuss › 1043050 › what-will-happen-if-you-use-length-function-on-2d-array-
What will happen if you use length function on 2-D Array.. ??? | Sololearn: Learn to code for FREE!
January 31, 2018 - Talking about Java, the length function always gives the number of elements in the array. So is the case with 2D arrays, as the array contains 2 elements (the two arrays are treated as 2 different elements), the number returned is 2. Take this ...