To get the dimensions of a two-dimensional (2D) array in Java, you can use the length
field of the array, which holds the number of rows in the array. To get the number of columns in a row, you can use the length
field of one of the rows.
Here's an example of how you can get the dimensions of a 2D array in Java:
int[][] numbers = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int rows = numbers.length; int columns = numbers[0].length;
In this example, the numbers
array is a 2D array containing three rows and three columns. The rows
variable holds the number of rows in the array, and the columns
variable holds the number of columns in a row.
You can also use a loop to iterate over the rows and columns of the array and perform operations on the elements.