title: Why can't Java ArrayList be accessed by unique key?
body: <p>I was passing the <a href="http://www.indiabix.com/online-test/java-programming-test/61" rel="nofollow noreferrer">Java test</a> and came across the following question (№8):</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>I've answered A and it is true. But why D is not true? I open the source of ArrayList and find the following chunk of code:</p>
  
  <pre><code>/**
   * The array buffer into which the elements of the ArrayList are stored.
   * The capacity of the ArrayList is the length of this array buffer. Any
   * empty ArrayList with elementData == EMPTY_ELEMENTDATA will be expanded to
   * DEFAULT_CAPACITY when the first element is added.
   */
  private transient Object[] elementData;
  </code></pre>
  
  <p>Since, we can access to any element of an ArrayList using a unique key (index of element). Why does such reasoning is wrong?</p>