1 / 6

Warm up

Warm up. Determine the value stored in each of the following: gradeTable [ 0 ][ 0 ] gradeTable [ 1 ][ 1 ] gradeTable [ 3 ][ 4 ] gradeTable [ 5 ][ 2 ]. More 2-D Arrays. Different Numbers of Cells per Row. Usually you think of a 2D array as a table

kalila
Télécharger la présentation

Warm up

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Warm up • Determine the value stored in each of the following: • gradeTable[ 0 ][ 0 ] • gradeTable[ 1 ][ 1 ] • gradeTable[ 3 ][ 4 ] • gradeTable[ 5 ][ 2 ]

  2. More 2-D Arrays

  3. Different Numbers of Cells per Row • Usually you think of a 2D array as a table • Is this possible:int[][] uneven = {{ 1, 9, 4 }, { 0, 2}, { 0, 1, 2, 3, 4 }};

  4. Different Numbers of Cells per Row • You have to think of "arrays of references to 1D arrays.“

  5. Different Numbers of Cells per Row • Determine the value stored in each of the following: • uneven[ 0 ][ 0 ] • uneven[ 1 ][ 1 ] • uneven[ 0 ][ 4 ] • uneven[ 2 ][ 4 ]

  6. Printing a 2D Array // declare and construct a 2D array int[][] uneven = { { 1, 9, 4 }, { 0, 2}, { 0, 1, 2, 3, 4 } }; // print out the array for(int row=0; row < uneven.length; row++) { System.out.print("Row " + row + ": "); for(int col=0; col < uneven[row].length; col++) System.out.print(uneven[row][col] + " "); System.out.println(); }

More Related