I learned 2D arrays si I though I would just take a stab at 3D but I cannot figure out the correct syntax. Here is what I have:
public class ThreeDArray { public static void main(String[] args) { int[][][] x = new int[2][3][4]; x[0][0][0] = 5; x[0][1][0] = 3; x[0][2][0] = 1; x[1][0][0] = 5; x[1][1][0] = 3; x[1][2][0] = 1; for(int[] i: x ) { for(int j : i) { for(int m : j) { System.out.print(m + " "); } } System.out.println(); } } }
here's the two errors I am getting:
ThreeDArray.java:15: error: incompatible types for(int[] i: x ) ^ required: int[] found: int[][] ThreeDArray.java:19: error: for-each not applicable to expression type for(int m : j) ^ required: array or java.lang.Iterable found: int 2 errors
thanks in advance!