Page 39 - PowerPoint Presentation
P. 39

Java Multi-Dimensional Arrays




          •      A multidimensional array is an array of arrays.


          •      To create a two-dimensional array, add each array within its own set of curly braces:






          •      myNumbers is now an array with two arrays as its elements.


          •       To access the elements of the myNumbers array, specify two indexes: one for the array, and




                 one for the element inside that array. This example accesses the third element (2) in the second

                 array (1) of myNumbers:











                                                                                                                                      39
   34   35   36   37   38   39   40   41   42   43   44