๐Ÿ“– Crammy ยท All study guides
AP Computer Science A ยท Unit 6

Arrays: every key term you need

11 flashcard terms for AP Computer Science A Unit 6, written to match the course framework. Study them here, then drill them as interactive flashcards โ€” free, no account needed.

Study this unit free โ†’
Arrays: Basics
Fixed-size collection of same type. Declaration: int[] arr = new int[5];. Index 0 to length-1.
Array Indexing
Access element: arr[i]. Range 0 to length-1. ArrayIndexOutOfBoundsException if invalid index.
Array Initialization
int[] arr = {1, 2, 3, 4, 5}; or int[] arr = new int[5]; (defaults to 0). Size set at creation.
Array Length
arr.length gives size (not method, property). Used in loops: for (int i=0; i<arr.length; i++).
Arrays as Parameters
Method receives array reference; modifications affect original array. Pass by reference (objects), not value.
Array Algorithms: Search
Linear search: loop through checking each element. Fastest when small. Binary search: requires sorted array; O(log n).
Array Algorithms: Sort
Arrays.sort(arr) built-in. Custom sort needs comparison logic (Comparable interface).
2D Arrays
int[][] matrix = new int[rows][cols];. Jagged arrays: each row different length. Access: matrix[i][j].
2D Array Traversal
Nested loops: for each row, for each column. Standard: row-major (right-to-left, top-to-bottom).
Arrays vs ArrayList
Array: fixed size, primitives allowed, faster. ArrayList: dynamic, objects only, slower. ArrayList wraps primitives (Integer, Double).
Unit 6 Summary
Arrays fixed-size collections; indexed 0 to length-1. 2D arrays for tables/matrices. Algorithms: search, sort. ArrayList more flexible.
Turn these into flashcards & quizzes โ†’

More AP Computer Science A guides