I'm trying to wrap my head around three-dimensional arrays. I understand that they are arrays of two-dimensional arrays, but the book I'm reading said something that confuses me.
In an exercise for the book I'm reading, it asks me to make a three-dimensional array for a full-color image. It gives a small example saying this:
If we decide to choose a three-dimensional array, here's how the array might be declared:
int[][][] colorImage = new int[numRows][numColumns][3];
However, wouldn't it be more effective like this?
int[][][] colorImage = new int[3][numRows][numColumns];
Where 3 is the rgb values, 0 being red, 1 being green, and 2 being blue. With the latter, each two-dimensional array would be storing the color value of the row and column, right? I just want to make sure I understand how to effectively use a three-dimensional array.
Any help will be greatly appreciated, thanks.