In Java, multi dimensional arrays are also referred to as arrays of arrays. 2D array is the commonly used and simplest multi-dimensional array. Generally ,2D arrays are referred to as one-dimensional arrays lists. 2D arrays are represented in a row-columns form on paper, and the terms "rows" and "columns" are used in computing.
public static void main(String ana)
int table=new int;
In this example a class twodim is created. In main method, two integer variables aa,bb are declared,which are used for the two dimensional array.Then, a two dimensional array is created new int, which is linked to a reference variable table of the array.After this, first for loop is used, wherein variable aa is initialized to 0, and aa condition aa<4 is checked.
If the condition aa<4 is true ,second for loop starts.
In this for loop
first, the value of bb is initialized to 0
Then, the condition bb<5 is checked.
If the condition bb<5 is true, table[aa][bb] is assigned a value that comes as a result of (aa*5)+bb+1;
Then the System.out.print(table[aa][bb]+" "); statement is used to print the value that is assigned to table[aa][bb].