Following is a main method which is stored in java file called examprep.java
Method :
public class Main
{
int columns = 2;
int rows = 2;
String[][] animals = new String[columns][rows];
animals[0][0] = "veg";
animals[0][1] = "deer";
animals[1][0] = "nonveg";
animals[1][1] = "lion";
for(int i = 0; i < rows; i++){
for(int j = 0; j < columns; j++){
System.out.println(animals[i][j]);
}
}
}
What is a multidimensional array ?
An array of arrays is a multidimensional array. When you want to store data in a tabular form, such as a table with rows and columns, multidimensional arrays are helpful.
An array with more than one dimension is referred to as a multi-dimensional array. It is an array of arrays and a multi-level array. The 2D array, often known as a two-dimensional array, is the most basic multi-dimensional array. Technically speaking, as you will see in the code, it is an array of arrays. A 2D array is also known as a matrix, a table with rows and columns, or a 2D array.
Declaring an array with many dimensions is comparable to declaring an array with one dimension. We must inform C that a 2D array has two dimensions.
Hence to conclude method in a java file is given above for the animal[][]list
To know more on arrays follow this link:
https://brainly.com/question/28061186
#SPJ4