title: How to create ArrayList (ArrayList<Integer>) from array (int[]) in Java
body: <p>I have seen the question: <a href="https://stackoverflow.com/questions/157944/how-to-create-arraylist-arraylistt-from-array-t">Create ArrayList from array</a></p>
  
  <p>However when I try that solution with following code, it doesn't quite work in all the cases:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.List;
  
  public class ToArrayList {
  
      public static void main(String[] args) {
          // this works
          String[] elements = new String[] { "Ryan", "Julie", "Bob" };
          List&lt;String&gt; list = new ArrayList&lt;String&gt;(Arrays.asList(elements));
          System.out.println(list);
  
          // this works
          List&lt;Integer&gt; intList = null;
          intList = Arrays.asList(3, 5);
          System.out.println(intList);
  
          int[] intArray = new int[] { 0, 1 };
          // this doesn't work!
          intList = new ArrayList&lt;Integer&gt;(Arrays.asList(intArray));
          System.out.println(intList);
      }
  }
  </code></pre>
  
  <p>What am I doing wrong here? Shouldn't the code <code>intList = new ArrayList&lt;Integer&gt;(Arrays.asList(intArray));</code> compile just fine?</p>