Here is the sample program to loop on 3 d Array
package test;
public class ThreeDArray {
public static void main(String[] args) {
int[][][] myArrays= new int[3][3][3];
for( int i=0; i<3; i++){
for(int j=0; j<3;j++){
for (int k = 0; k < 3; k++) {
myArrays[i][j][k]=Integer.parseInt(String.valueOf(i)+String.valueOf(j)+String.valueOf(k));
System.out.println(myArrays[i][j][k]);
System.out.println(+i+""+j+""+k);
}
}
}
}
}
Example 2
package test;
public class ThreeDArray {
/**
* @param args
*/
public static void main(String[] args) {
int[][][] myArrays=
{
{
{11, 12, 13},
{14, 15, 16},
{17, 18, 19}
},
{
{21, 22, 23},
{24, 25, 26},
{27, 28, 29}
},
{
{31, 32, 33},
{34, 35, 36},
{17, 18, 19}
},
};
for( int i=0; i<3; i++){
for(int j=0; j<3;j++){
for (int k = 0; k < 3; k++) {
System.out.println(myArrays[i][j][k]);
System.out.println(+i+""+j+""+k);
}
}
}
}
}
package test;
public class ThreeDArray {
public static void main(String[] args) {
int[][][] myArrays= new int[3][3][3];
for( int i=0; i<3; i++){
for(int j=0; j<3;j++){
for (int k = 0; k < 3; k++) {
myArrays[i][j][k]=Integer.parseInt(String.valueOf(i)+String.valueOf(j)+String.valueOf(k));
System.out.println(myArrays[i][j][k]);
System.out.println(+i+""+j+""+k);
}
}
}
}
}
Example 2
package test;
public class ThreeDArray {
/**
* @param args
*/
public static void main(String[] args) {
int[][][] myArrays=
{
{
{11, 12, 13},
{14, 15, 16},
{17, 18, 19}
},
{
{21, 22, 23},
{24, 25, 26},
{27, 28, 29}
},
{
{31, 32, 33},
{34, 35, 36},
{17, 18, 19}
},
};
for( int i=0; i<3; i++){
for(int j=0; j<3;j++){
for (int k = 0; k < 3; k++) {
System.out.println(myArrays[i][j][k]);
System.out.println(+i+""+j+""+k);
}
}
}
}
}
Comments
Post a Comment