How to use Multi Dimensional Array in Java,
The Simple Java Multi Dimensional Example program shows how to declare, initialize a Multi Dimensional Array and print data from it.
Multi Dimensional Array Example Program:
// A simple java program which shows the multidimensional array declaration, Initialization and Printing.
public class MultiDimensionalArray {
public static void main(String args[]){
// Array declaration and initialization
int twoDimension[][] = {{1,2,3,4},{4,3,2,1},{5,6,7,8}};
for(int i=0; i < 3 ; i++){
for (int j=0; j < 4 ; j++){
System.out.print(twoDimension[i][j]+" ");
}
System.out.println();
}
}
}
Program Output:
1 2 3 4
4 3 2 1
5 6 7 8
No comments :
Post a Comment