title: java: multidimensional generic array creation
body: <p>How do I make a multidimensional array of generic items in java?</p>
  
  <p>Consider the class:</p>
  
  <pre><code>class A&lt;T&gt;
    {
      T t;
      public A(T t) { this.t = t; }
    }
  </code></pre>
  
  <p>When I try to create a multidimensional array: </p>
  
  <pre><code>A&lt;String&gt;[][] array = new A&lt;String&gt;[2][3];
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>generic array creation
  A&lt;String&gt;[][] array = new A&lt;String&gt;[2][3];
                        ^
  </code></pre>
  
  <p>I tried the following:</p>
  
  <pre><code>A&lt;String&gt;[][] array = (A&lt;String&gt;[][]) (new Object[2]3]);
  </code></pre>
  
  <p>But that just throws: <code>java.lang.ClassCastException</code></p>
  
  <p>What's the fix?</p>
  
  <p>(I anticipate people recommending to use lists. Please explain how to achieve this using arrays.)</p>