Multi dimensional array
In multi dimensional array,
- Elements will be stored in rows and columns.
- Based on index we can access the elements
Syntax
NameOfTheDataType variableName[][];
NameOfTheDataType variableName[][];
Example
int a[3][3];
Thanks for your time.
-------------------------------------------------------------------
Program : To print vlaues from an multi dimentional array
Program name : ArrayDemo5.java
Output :
1 1 1
4 4 4
5 5 5
class ArrayDemo5
{
public static void main(String args[])
{
int arr[][]={{1,1,1},{4,4,4},{5,5,5}};
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}
}
Compile : javac ArrayDemo5.java
Run : java ArrayDemo5
Output :
1 1 1
4 4 4
5 5 5
-------------------------------------------------------------------
Nireekshan