AP® Computer Science A · Unit 4 · Topic 4.11

Initializer Lists and Row-Column Indexing

Watch it explained

  1. How it worksHow does a nested initializer list build each row before the rows become a grid?
  2. Worked exampleFind the value at index [1][2] of { {1,2,3}, {4,5,6}, {7,8,9} }.
  3. Worked exampleTrace setting grid[2][0] to 99 and find which single cell in the picture changes.
  4. Common mistakeWhy doesn't grid[2][3] exist inside a 3 by 3 grid?

Check yourself

Your turn1 of 2
A 3 by 3 grid is filled so that the value at grid[row][col] always equals row·10 + col. What is the value at grid[1][1]?

End of topic.