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