Two Dimensional Arrays

4. Headings are not part of the Array


Answer:

gradeTable[ 5 ][ 3 ] = 0;

Headings are not part of the Array

Annotation 2020-03-26 205058The row and column numbers are not part of the array. They are usually shown in pictures of an array, but the array object does not explicitly contain the indexes. When you ask for

gradeTable[ 5 ][ 3 ]

Java knows what cell you mean and goes there directly.

More Important Stuff:

      • Rows are numbered from 0 to N-1, where N is the number of rows
      • Columns are numbered from 0 to M-1, where M is the number of columns.
      • A 2D array with N rows and M columns per row will have N times M number of cells.
      • However, it is possible for a 2D array to have a different number of cells in each row.

Details about these issues will follow.


Question 4:

With the example array, will the following statement work?

gradeTable[7][2] = 82 ;