I konw the three dimensional (3D) array can be thought of as an array of arrays of arrays. And i have int[3][4][2] 3Darray i can initialize using for loop
Example
public class JavaProgram
{
public static void main(String args[])
{
int arr[][][] = new int[3][4][2];
int i, j, k, num=1;
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
for(k=0; k<2; k++)
{
arr[i][j][k] = num;
num++;
}
}
}
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
for(k=0; k<2; k++)
{
System.out.print("arr[" +i+ "][" +j+ "][" +k+ "] = " +arr[i][j][k]+ "\t");
}
System.out.println();
}
System.out.println();
}
}
}
output look like
And i have 3d Array like
int[][][] matrix = {{{1, 2, 3},{4, 5, 6}}, {
{10, 20, 30},{40, 50, 60}}};
And i not able to find out position all elements like matrix[0][0][0]=1. What is index value of other elements. please any one help me to find
