Same idea — a collection of items. But one has a fixed size and the other can grow. Try adding and removing from each and watch what happens.
| Operation | Array | ArrayList |
|---|---|---|
| Create | new String[5] | new ArrayList<String>() |
| Size / length | kids.length | kids.size() |
| Get item | kids[0] | kids.get(0) |
| Set item | kids[0] = "Ezra" | kids.set(0, "Ezra") |
| Add item | can't — size fixed | kids.add("Ezra") |
| Remove item | can't — leaves null | kids.remove(0) — shifts others |
| Holds primitives (int, double)? | yes — int[] nums | no — only objects (Integer, Double) |
| Import needed? | no | java.util.ArrayList |
Tip: try adding 6 names to the array. On the 6th, it throws. Try the same on the ArrayList — it just keeps going.