title: Java : autoboxing of an Object array of integers, cast to int from LinkedList.toArray()
body: <p>I would like to use code similar to the following:</p>
  
  <pre><code>int letterIndex[];
  LinkedList&lt;Integer&gt; letterList;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>if(!letterList.isEmpty()) letterIndex = (Integer[])letterList.toArray();
  </code></pre>
  
  <p>However, it is not allowed, and apparently the cast to <code>Integer[]</code> is not autoboxed when converting to <code>int[]</code>. How would I accomplish the equivalent without declaring <code>letterIndex</code> as <code>Integer[]</code> instead of <code>int[]</code>?</p>