1/52
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Data collection
A structure that stores many values and lets you work with them as a group (e.g., arrays, ArrayLists, 2D arrays).
Index-based access
Referring to collection elements by position (0, 1, 2, …) to read or update values.
Array
A fixed-size, indexed object that stores elements of the same type.
ArrayList
A resizable, indexed list from the Java Collections Framework that can grow/shrink as elements are added/removed.
2D array
An array whose elements are arrays; used to model grids/tables (rows and columns).
Reference
A value that points to an object’s location; collection variables store references, not the entire object.
Object (in context of collections)
A heap-allocated entity in Java; arrays, ArrayLists, and 2D arrays are objects and are referenced by variables.
Aliasing
When two variables refer to the same object, so changes through one variable are visible through the other.
Side effect (collections)
A method call that changes the original array/ArrayList passed in (because the reference points to the same object).
Fixed size
Array property: once created, an array’s length cannot change.
0-based indexing
Indexing system where the first element is at index 0 and the last is at index length-1 (or size-1).
Homogeneous type
Array rule: all elements in an array must be the same declared type (e.g., int[] only holds int).
Array initializer
Syntax that creates and fills an array at once, e.g., int[] a = {90, 85, 100};
Default values (arrays)
Values automatically stored in a newly created array: 0 (int), 0.0 (double), false (boolean), null (reference types).
null
The default value for reference types; indicates “no object reference.”
ArrayIndexOutOfBoundsException
Runtime error thrown when accessing an array with an invalid index (
length (array field)
Array property that gives the number of elements; used as arr.length (no parentheses).
size() (ArrayList method)
Returns the current number of elements in an ArrayList.
Off-by-one error
A boundary mistake in indexing/loop bounds, such as using i <= arr.length instead of i < arr.length.
Traversal
Systematically visiting elements of a collection to compute a result or modify the collection.
Index-based for loop (arrays)
Common traversal pattern: for (int i = 0; i < arr.length; i++) { … }
Enhanced for loop (for-each)
Traversal that iterates over values directly (no explicit index), e.g., for (int x : arr) { … }
For-each variable is a copy (primitives)
In a for-each loop over primitives, the loop variable holds a copy; changing it does not change the array element.
Accumulator
A variable (like sum) initialized before a loop and updated each iteration to combine values.
Accumulation (sum/total) algorithm
Traversal pattern that adds each element into an accumulator to compute a total (and often an average).
Integer division pitfall
When dividing ints in Java, the result is truncated; use double if you need a decimal average.
Maximum/minimum algorithm
Pattern that tracks a “best so far” value, typically initialized to the first element and updated via comparisons.
Counting with a condition
Traversal pattern that increments a counter when elements satisfy a boolean test (e.g., count values equal to 10).
In-place replacement (map/transform)
Algorithm that overwrites each element using its old value, e.g., arr[i] = arr[i] * arr[i].
Shifting (array removal idea)
Moving elements left/right to simulate insertion/removal in an array since its length can’t change.
Logical size
A separate variable used with arrays to track how many positions are currently “valid” after shifting/removal-like operations.
Resizable
ArrayList property: it can automatically grow or shrink as elements are added or removed.
Wrapper class
An object type that represents a primitive for use in collections (e.g., Integer for int, Double for double).
Autoboxing/unboxing
Java automatically converts between primitives and wrapper objects when needed (e.g., int ↔ Integer).
get(i) (ArrayList)
Returns the element at index i in an ArrayList.
set(i, value) (ArrayList)
Replaces the element at index i and returns the old element.
add(value) (ArrayList)
Appends an element to the end of an ArrayList.
add(i, value) (ArrayList)
Inserts an element at index i and shifts later elements to the right.
remove(i) (ArrayList)
Removes the element at index i, shifts later elements left, and returns the removed element.
Shifting behavior (ArrayList)
After insertion/removal at an index, later elements move to keep indices contiguous.
Concurrent modification (enhanced for loop)
Adding/removing elements from an ArrayList during an enhanced for loop is not allowed and typically causes a runtime error.
Backward traversal for removals
Looping from size()-1 down to 0 to safely remove elements without skipping due to shifting.
remove(int) vs remove(Object) (ArrayList
For ArrayList
== vs .equals() (objects)
== checks if two references are the same object; .equals() checks logical/content equality (commonly needed in collections).
Linear search
Searching by checking each element in order until a match is found or the end is reached.
Sentinel value (-1)
A special return value often used to indicate “not found” in search methods.
Collections.sort
Library method that sorts an ArrayList in place according to natural ordering (e.g., Strings alphabetically).
Arrays.sort
Library method that sorts an array in place (e.g., int[] in ascending order).
In-place sort side effect
Sorting rearranges the same collection object; the original order is lost unless you copied it first.
Ragged array
A 2D array where rows can have different lengths because each row is a separate array.
Row-major order
2D traversal that visits all columns of row 0, then row 1, and so on (nested loops over rows then columns).
2D array length rules
grid.length is the number of rows; grid[r].length is the number of columns in row r.
Bounds check (neighbors in a grid)
Verifying indices are valid before accessing adjacent cells (e.g., ensure c+1 < grid[r].length before using grid[r][c+1]).