AP Computer Science A ยท Unit 8
2D Arrays: every key term you need
10 flashcard terms for AP Computer Science A Unit 8, written to match the course framework. Study them here, then drill them as interactive flashcards โ free, no account needed.
Study this unit free โ
2D Arrays Array of arrays; represents table/matrix. int[][] matrix = new int[rows][cols];. Access: matrix[i][j].
2D Array Initialization int[][] matrix = {{1,2,3}, {4,5,6}};. Rows: matrix.length, columns: matrix[0].length (if rectangular).
2D Array Iteration Nested loops: outer row, inner column. for(int i=0; i<matrix.length; i++) for(int j=0; j<matrix[i].length; j++).
Ragged Arrays Each row different length. int[][] ragged = new int[3][]; ragged[0] = new int[2]; ragged[1] = new int[5];.
2D Array Algorithms Row sum: sum column j for each i. Column sum: sum row i for each j. Diagonal: matrix[i][i]. Reverse: swap.
Matrix Operations Addition: new[i][j] = a[i][j] + b[i][j]. Multiplication: complex (inner dimension must match).
Searching 2D Arrays Linear search: nested loops checking each element. 2D index: track both i,j. Return found or not found.
2D Array Pass to Method Method receives reference. Modifications affect original. Example: void fillMatrix(int[][] m) modifies array outside.
ArrayList of ArrayLists ArrayList<ArrayList<Integer>> = dynamic 2D structure. Allows ragged dimensions. More flexibility than 2D array.
Unit 8 Summary 2D arrays represent tables/matrices. Nested loops iterate. Ragged arrays allow flexible dimensions. Support complex algorithms.
Turn these into flashcards & quizzes โ
More AP Computer Science A guides
Crammy is a free all-in-one study hub for AP, A-Level, GCSE, IB and test prep โ flashcards, quizzes, practice exams, an AI tutor, and adaptive study sessions. Start studying free .
SAT® and AP® are registered trademarks of the College Board. ACT® is a registered trademark of ACT, Inc. None is affiliated with, sponsors, or endorses Crammy, and none has reviewed our practice material. All questions and explanations here are original. Legal & attributions .