0
How to write program in array with 3 dimensional
2 Respostas
+ 2
typehere[][][] arrayname = new typehere[inthere][inthere][inthere];
Replace 'typehere' with the type of your choice (int, char, Object, etc.), 'arrayname' with the name of your 3D array, and 'inthere' with the amount of array elements in each array. You could also initialize it with something like:
{{{1}, {2}}, {{2}, {3}}, {{4}, {5}}};
instead of:
new int[3][2][1];
+ 2
First, you would need a reason to have the 3 dimension array. With a valid reason, the program becomes easier to understand and write.
A valid reason would be making a spreadsheet program. The columns and rows displayed on the page would be 2 of the dimensions and the page tabs at the bottom of the page would be the third. With this image in mind, coding becomes a lot easier.