I am trying to wrap my head around three-dimensional arrays. I understand that these are arrays of two-dimensional arrays, but the book I'm reading says what confuses me.
In the exercise for the book I'm reading, I am asked to create a three-dimensional array for a full-color image. This gives a small example:
If we decide to select a three-dimensional array, here is how an array can be declared:
int[][][] colorImage = new int[numRows][numColumns][3];
However, it would not be more effective, how is it?
int[][][] colorImage = new int[3][numRows][numColumns];
Where 3 is the rgb value, 0 is red, 1 is green, and 2 is blue. With the latter, each two-dimensional array will store the color value of the row and column, right? I just want to make sure that I understand how to use a three-dimensional array efficiently.
Any help would be greatly appreciated, thanks.