8.1 2D Arrays
Enduring Understanding
To manage large amounts of data or complex relationships in data, programmers write code that groups the data together into a single data structure without creating individual variables for each value.
Learning Objective
Represent collections of related primitive or object reference data using two-dimensional (2D) array objects.
Essential Knowledge
2D arrays are stored as arrays of arrays. Therefore, the way 2D arrays are created and indexed is similar to 1D array objects.
Exclusion Statement: 2D array objects that are not rectangular are outside the scope of the course and AP Exam.
For the purposes of the exam, when accessing the element at arr[first][second], the first index is used for rows, the second index is used for columns.
The initializer list used to create and initialize a 2D array consists of initializer lists that represent 1D arrays.
The square brackets [row][col] are used to access and modify an element in a 2D array.
“Row-major order” refers to an ordering of 2D array elements where traversal occurs across each row, while “column-major order” traversal occurs down each column.
Last updated
Was this helpful?