How to Get Rows and Columns Count of a 2D Array in Java? [Duplicate]
For an Array in Java, We Can Get the Length of the Array with Array_Name. Length. Similarly, How Would One Get the Number of Rows and Columns of a 2D Array? 0...
For an array in Java, we can get the length of the array with array_name.length. Similarly, how would one get the number of rows and columns of a 2D array?
Well you probably want array_name.length for getting the count of the rows and array_name[0].length for the columns. That is, if you defined your array like so:
T[][] array_name = new T[row][col];
array_name.length // row
array_name[0].length // col