MultiDimensionalArray
In this program we illustrate how to declare Multi Dimensional arrays.We have a used a 2D array to explain this concept.
/*
http://www.ProbCOMP.com
In this program we illustrate how to declare Multi Dimensional arrays.
We have a used a 2D array to explain this concept.
*/
public class MultiDimensionalArray{
public static void main(String args[])
{
int[][] array1 = {{1, 2, 3},{4, 5, 6}};
for (int i = 0; i < array1.length; i++) {
for (int j = 0; j < array1[i].length; j++) {
System.out.println(array1[i][j]);
}
}
//declaring a fixed length array
int[][] array2 = new int[2][3];
}
}
Download Program


