Java 2D array visualizer
A 2D array in Java is an array of rows, where each row is its own array. Step through the nested loops and watch every cell fill in, row by row.
Call stack
1
main()
Step 1/1
What to watch
- new int[3][4] makes three row arrays, each with four zeros.
- The outer loop picks a row and the inner loop walks across its columns.
- grid[row].length is the number of columns in that row.
Try changing it
- Swap the loops so it fills column by column.
- Make the rows different lengths and see how the arrays change.
Edit the code above and press Visualize to see your version run.
More Java examples
- Java recursion visualizer
- Bubble sort in Java, step by step
- Binary search in Java, step by step
- Java ArrayList visualizer
- Java linked list visualizer
- Java objects and references, visualized
Or open the Java visualizer and paste your own code.