title: How does one instantiate an array of maps in Java?
body: <p>I can declare an array of maps using generics to specify the map type:</p>
  
  <pre><code>private Map&lt;String, Integer&gt;[] myMaps;
  </code></pre>
  
  <p>However, I can't figure out how to instantiate it properly:</p>
  
  <pre><code>myMaps = new HashMap&lt;String, Integer&gt;[count]; // gives "generic array creation" error
  myMaps = new HashMap[count]; // gives an "unchecked or unsafe operation" warning
  myMaps = (Map&lt;String, Integer&gt;[])new HashMap[count]; // also gives warning
  </code></pre>
  
  <p>How can I instantiate this array of maps without getting a compiler error or warning?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Thank you all for your replies. I ended up going with the List suggestion.</p>