⊞
2D Array Traversal
AP Computer Science A · Arrays
Matrix Under the Hood

In Java, a 2D Array is just an array of arrays! arr[row][col].

Access Boundaries
arr.length = Number of Rows
arr[0].length = Number of Columns in Row 0
Traversal Patterns
Row-Major: Scan left-to-right, then down. Nested loop with row on the outside.
Column-Major: Scan top-to-bottom, then right. Nested loop with col on the outside.
Tags
2D ArrayMatrixRow-MajorNested Loops
Traversal Pattern

Animation Control

Variable Inspector
Current Row (r):
-
Current Col (c):
-
Value at arr[r][c]:
-