zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

Glossary

2

2D Array

Criticality: 3

A 2D array in Java is an array of arrays, forming a table-like structure with rows and columns.

Example:

Imagine a spreadsheet where each cell holds a number; that's like a 2D array of integers.

D

Declaration (of 2D array)

Criticality: 2

The process of specifying the data type and name for a 2D array, reserving its type but not its memory.

Example:

int[][] gameBoard; declares a variable gameBoard that can hold a 2D array of integers.

I

Indices (for 2D array)

Criticality: 3

Numerical positions used to access specific elements within a 2D array, consisting of a row index and a column index.

Example:

To find the score in the second row, third column of a scores array, you'd use scores[1][2], where 1 and 2 are the indices.

Initialization (of 2D array)

Criticality: 3

The process of allocating memory for a 2D array and optionally assigning initial values to its elements.

Example:

int[][] scores = new int[5][3]; initializes a 5x3 array to store scores, setting all elements to their default value (0 for int).

N

Nested Loops

Criticality: 3

A programming construct where one loop is placed inside another, commonly used to iterate through multi-dimensional data structures like 2D arrays.

Example:

To print every element of a matrix, you'd use nested loops: an outer loop for rows and an inner loop for columns.

Z

Zero-based indexing

Criticality: 3

A system where the first element of an array or sequence is at index 0, the second at index 1, and so on.

Example:

In a 2D array with 3 rows, the valid row zero-based indices are 0, 1, and 2.