title: How to convert hashmap to Array of entries
body: <p>I have a map</p>
  
  <p><code>private HashMap&lt;Character, Integer&gt; map;</code></p>
  
  <p>I want to convert it to array  but when I do that/I get this:</p>
  
  <pre><code>Entry&lt;Character, Integer&gt; t = map.entrySet().toArray();    
  **Type mismatch: cannot convert from Object[] to Map.Entry&lt;Character,Integer&gt;**
  </code></pre>
  
  <hr>
  
  <pre><code>Entry&lt;Character, Integer&gt;[] t = null;
  map.entrySet().toArray(t); 
  **Exception in thread "main" java.lang.NullPointerException**
  </code></pre>
  
  <hr>
  
  <pre><code>Entry&lt;Character, Integer&gt;[] t = new Entry&lt;Character, Integer&gt;[1];
  map.entrySet().toArray(t); 
     **Cannot create a generic array of Map.Entry&lt;Character,Integer&gt;**
  </code></pre>
  
  <hr>
  
  <pre><code>Entry&lt;Character, Integer&gt;[] t = null;
  t = map.entrySet().toArray(t); 
  **Exception in thread "main" java.lang.NullPointerException**
  </code></pre>
  
  <p><strong>So how to convert <code>HashMap</code> to <code>Array</code>?</strong> None of answers  found in other subjects work.</p>