title: casting Arrays.asList causing exception: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
body: <p>I'm new to Java and am trying to understand why the first code snippet doesn't cause this exception but the second one does.  Since a string array is passed into Arrays.asList in both cases, shouldn't both snippets produce an exception or not produce an exception?  </p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
  </code></pre>
  
  <p>First snippet (causes no exception):</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;String&gt;&gt; stuff = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  String line = "a,b,cdef,g";
  String delim = ",";
  String[] pieces = line.split(delim);
  stuff.add((ArrayList&lt;String&gt;) Arrays.asList(pieces));
  </code></pre>
  
  <p>Second snippet (causes above exception):</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;String&gt;&gt; stuff = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  String[] titles = {"ticker", "grade", "score"};
  stuff.add((ArrayList&lt;String&gt;) Arrays.asList(titles));
  </code></pre>
  
  <p>If relevant, I'm using JavaSE 1.6 in Eclipse Helios.</p>