title: Why doesn't type erasure work with arrays in Java?
body: <p>I noticed we're unable to create arrays of a generic type in Java, like below:</p>
  
  <pre><code>public class ExampleClass&lt;G&gt; {
    private G[] genericArray = new G[arraySize];
  }
  </code></pre>
  
  <p>I've read that this is due to the way Java handles generics, using type erasure. My understanding of type erasure is that the generic is just replaced by the most specific superclass container - so if we provide no bound, every instance of <code>G</code> is just replaced by <code>Object</code>.</p>
  
  <p>Why can't this be done with the array, creating an array of type <code>Object</code>?</p>