Trying to understand what boolean[][][] is
As the title says I'm trying to figure out how boolean[][][] works. I've got some code i was trying to understand, but I've never seen this before as I've only been doing java for a month.
Here is a snippet of the code I'm trying to figure out.
Code java:
int goal;
boolean[][][] computed;
double[][][] p;
boolean[][][] roll;
computed = new boolean[goal][goal][goal];
if (computed[i][j][k]) return p[i][j][k];
Re: Trying to understand what boolean[][][] is
Re: Trying to understand what boolean[][][] is
An old version of something I wrote once implemented a 3D grid laid out in layers, rows and columns. At each point in the grid a value was either true or false, and I used boolean[][][] to represent it. To get or set the value of a point in the 3D grid, I once coded this:
Code java:
boolean[][][] example;
// set a single point (2, 1, 4) in the 3D space
example[2][1][4] = false;
Watch out for nested arrays in Java (it doesn't have multidimensional arrays) - your example may look like a cuboid 3D space, but in Java boolean[][][] is an array of arrays of boolean arrays. Each individual array can have a different length.