Java ArrayList visualizer
An ArrayList keeps its items in order and shifts them when you insert or remove. Step through the program and watch the list change after every call.
Call stack
1
main()
Step 1/1
What to watch
- add puts each name at the end of the list.
- add(1, ...) inserts at index 1, so every item after it moves one place to the right.
- remove takes an item out and the items after it slide left to close the gap.
Try changing it
- Call remove(0) instead of removing by name and compare the result.
- Add a loop that removes every name longer than three letters.
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 linked list visualizer
- Java objects and references, visualized
- Java 2D array visualizer
Or open the Java visualizer and paste your own code.