# Multi Dimensional Array

### How to declare an array:

int i[ ] [ ]=new int;// here it shows structure of two dimensional array. Two dimensional means the array element can contain another Array as values. Something like matrix format i.e. in format of rows and columns. Here  means its contain total 3 rows and each row contain 2 columns. initialize two Dimensional Array

### How to populate two dimensional array:

If we want to populate two dimensional array we should use the index in matrix format i.e rows and columns.  here 3 represents number of rows and 2 represents number of columns. Means for each row there are 2 columns.

#### Example 1: populate two dimensional array

#### Example 2:

Two dimensional array with anonymous arrays.

String s1[ ][ ]={{“a”,”b”},{“1”,”2”},{“p”,”q”}}; Two dimensional array with anonymous arrays

### Example 1:

``````

public class ArrayDemo
{
public static void main(String[] args)
{
String s1[ ][ ] = {{“java”,”j2ee”},{“mysql”,”oracle”},{“tomcat”,”jboss”}};
for ( int i=0;i< s1.length;i++)
{
String sub[ ]=s1[i];
for ( int j=0;j< sub.length;i++)
{
String s=sub[i];  or  String s = s1[i][j];
System.out.println(“Value at[“+i+”][“+j+”] is : ”+s);
}
}
}
}                  Output:
Value at  is : java
Value at  is : j2ee
Value at  is : mysql
Value at  is : oracle
Value at  is : tomcat
Value at  is : jboss
``````

### Limitations of Arrays:

• First we can initialize the array size that is fixed. We can’t increase (or) decrease the array size.

• Array can hold only one type of data type values. It can’t hold the multiple data type values.

• Manipulation of data is very difficult.

• Customization is not possible.

• In order to overcome this draw back,sun people came up with one new concept it’s named as “collections framework”.