title: Why is there an ArrayList declaration within java.util.Arrays
body: <p>In JDK 1.7, there is an <code>ArrayList</code> declaration which is used by <code>asList</code>.</p>
  
  <p>Why did they make a new <code>private static class</code> and not use <code>java.util.ArrayList</code>:</p>
  
  <pre><code>@SafeVarargs
  public static &lt;T&gt; List&lt;T&gt; asList(T... a) {
      return new ArrayList&lt;&gt;(a);
  }
  
  /**
   * @serial include
   */
  private static class ArrayList&lt;E&gt; extends AbstractList&lt;E&gt;
      implements RandomAccess, java.io.Serializable
  {
      private static final long serialVersionUID = -2764017481108945198L;
      private final E[] a;
  
      ArrayList(E[] array) {
          if (array==null)
              throw new NullPointerException();
          a = array;
      }
  
      public int size() {
          return a.length;
      }
  
      public Object[] toArray() {
          return a.clone();
      }
  
      public &lt;T&gt; T[] toArray(T[] a) {
          int size = size();
          if (a.length &lt; size)
              return Arrays.copyOf(this.a, size,
                                   (Class&lt;? extends T[]&gt;) a.getClass());
          System.arraycopy(this.a, 0, a, 0, size);
          if (a.length &gt; size)
              a[size] = null;
          return a;
      }
  
      public E get(int index) {
          return a[index];
      }
  
      public E set(int index, E element) {
          E oldValue = a[index];
          a[index] = element;
          return oldValue;
      }
  
      public int indexOf(Object o) {
          if (o==null) {
              for (int i=0; i&lt;a.length; i++)
                  if (a[i]==null)
                      return i;
          } else {
              for (int i=0; i&lt;a.length; i++)
                  if (o.equals(a[i]))
                      return i;
          }
          return -1;
      }
  
      public boolean contains(Object o) {
          return indexOf(o) != -1;
      }
  }
  </code></pre>