The point of Java's ArrayLists is that they adjust their length automatically whenever items are inserted or deleted. If I understand it correctly, ArrayLists are wrappers around primitive arrays.
I was taught that:
- arrays are data structures that offer random access in O(1) but can do insertion and deletion only in O(n), while
- lists offer insertion and deletion in O(1) but provide random access only in O(n),
meaning that a data structure can't be an array and a list at the same time.
Why then does Java call it “ArrayList” – isn't that an oxymoron? (Wouldn't “DynamicArray” be more appropriate?) Or do ArrayLists actually have a “lists trope”?