title: Cast object array to generic array
body: <p>Currently, I am viewing the source code of java.util.ArrayList. Now I find the function <strong>public void ensureCapacity(int minCapacity)</strong> casts an object array to a generic array, just like code below:</p>
  
  <pre><code> E[] newData = (E[]) new Object[Math.max(current * 2, minCapacity)];
  </code></pre>
  
  <p>However, when I declare the array to a specific type, IDE will show an error.</p>
  
  <pre><code>Object[] arr = new Object[10];
      int[] arr1 = (int[]) new Object[arr.length];
  </code></pre>
  
  <p>Any one is able to tell me the differences between them? Thanks a lot.</p>