I passed the Java test and came across the following question (# 8):
Which statement is true for the class java.util.ArrayList? A. The elements in the collection are ordered. B. The collection is guaranteed to be immutable. C. The elements in the collection are guaranteed to be unique. D. The elements in the collection are accessed using a unique key.
I answered A, and it is true. But why is D not true? I open the ArrayList source and find the following code snippet:
private transient Object[] elementData;
Since we can access any ArrayList element using a unique key (element index). Why is this reasoning wrong?
user2953119
source share