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?
1 Answer
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 3