SAT / PSAT
SAT / PSAT Prep
History & Social Science
AP World History AP US History AP European History AP Human Geography AP US Government & Politics AP Psychology AP Macroeconomics AP Microeconomics
English
AP English Language & Composition AP English Literature & Composition
Math & Computer Science
AP Calculus AB/BC AP Precalculus AP Statistics AP Computer Science A AP Computer Science Principles
Sciences
AP Biology AP Chemistry AP Environmental Science AP Physics 1 AP Physics 2
World Languages & Arts
AP Spanish Language AP Art History AP Music Theory Start studying →
Unit 4 · Data Collections Flashcards Cheat Sheet Essentials Visual Review MC Practice FRQ Practice

AP Computer Science A Unit 4 Essentials

The must-know terms and core concepts for Unit 4: Data Collections. Every vocabulary word, collection, and algorithm you need to master.

← Back to Unit 4 hub
Key Concept 1
Arrays and ArrayList store collections you traverse with loops
An array is a fixed-size, indexed collection (indices 0 to length−1, size given by the field arr.length); an ArrayList is a resizable list of objects with methods add, get, set, remove, and size(). You process either with traversals — a standard for loop for index access, or the enhanced for-each loop to read each element — implementing standard algorithms like finding a min/max, summing, counting, and filtering. Because ArrayList stores objects, it uses wrapper classes (Integer, Double) with autoboxing.
Array ArrayList Traversals
Key Concept 2
2D arrays are grids traversed with nested loops
A 2D array is an array of arrays — a rectangular grid accessed as matrix[row][col]. The number of rows is matrix.length and the number of columns is matrix[0].length. You traverse it with nested loops (row-major order: outer loop over rows, inner over columns) to implement algorithms across the whole grid. You can also read data into collections from text files using a Scanner.
2D Array Nested Loops Text Files
Key Concept 3
Searching, sorting, and recursion are the standard algorithms
Sequential (linear) search checks each element in turn and works on unsorted data; binary search halves a sorted array each step and is far faster. The standard sorts are selection sort (repeatedly swap in the smallest remaining element) and insertion sort (insert each element into a growing sorted region). Recursion — a method that calls itself with a base case and a recursive case — expresses algorithms like recursive binary search and merge sort.
Searching Sorting Recursion
Array
A fixed-size, indexed collection of same-type elements.
Arrays
Index
Position in an array, from 0 to length−1.
Arrays
arr.length
The size of an array (a field, no parentheses).
Arrays
ArrayIndexOutOfBoundsException
Run-time error from an invalid index.
Arrays
Traversal
Visiting each element of a collection.
Traversals
Enhanced for (for-each)
for (T x : coll) — reads elements, can’t assign/remove.
Traversals
ArrayList
A resizable list of objects (java.util).
ArrayList
add / get / set / remove / size
The core ArrayList methods.
ArrayList
Wrapper class
Integer/Double, wrapping a primitive as an object.
ArrayList
Autoboxing / unboxing
Automatic primitive↔wrapper conversion.
ArrayList
2D array
An array of arrays; a grid matrix[row][col].
2D Arrays
Row-major traversal
Nested loops: outer rows, inner columns.
2D Arrays
Text file / Scanner
Reading data from a file with a Scanner.
Files
Sequential (linear) search
Check each element until found (unsorted).
Searching
Binary search
Halve a sorted array each step.
Searching
Selection sort
Repeatedly swap in the smallest remaining element.
Sorting
Insertion sort
Insert each element into a sorted region.
Sorting
Recursion
A method that calls itself.
Recursion
Base case
The stopping condition of a recursion.
Recursion
Merge sort
A recursive divide-and-merge sort.
Recursion