|
|
||
| You are here: | ||
|
2D arrays are not a mastery aspect but questions about them can be asked or algorithms set in the exam.
3D arrays are not part of the syllabus, we just thought you might be interested (yeah, right).
|
Arrays of more than one dimension
The elements of a 2D array are accessed by referring to the row then the column , thus board[1][2] contains the value 4 (rather than 3 which is in board[2][1]). In the above example board could be a boolean or int type or even char using X's and O's. Arrays are defined using separate sets of square brackets for each dimension: int board [] [] = new int [3][3]; Arrays of larger dimensions than 2 are possible (but not so easy to draw!). A three dimensional array can be thought of as a cube, or represented in 2D as a series of grids.
A set of 2D arrays representing a cube So the value 256 in the back of the cube would be referred to by cube[1][2][2] [row][col][plane]. The chomp and more 2D arrays pages show example Classes which use 2D arrays.
Related: [ Java home | Previous: Array Operations | Next: Chomp ] |
|
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: May 31, 2009 |