title: Map.clear() vs new Map : Which one will be better?
body: <p>I have a Map as syntax as <code>Map&lt;String, String&gt; testMap = new HashMap&lt;String, String&gt;();</code>. 
  In this map there can be 1000 data. </p>
  
  <p>When my application requires to new list of data, then I must clear the Map. But when I saw the code of Map.clear() as </p>
  
  <pre><code>/**
       * Removes all of the mappings from this map.
       * The map will be empty after this call returns.
       */
      public void clear() {
          modCount++;
          Entry[] tab = table;
          for (int i = 0; i &lt; tab.length; i++)
              tab[i] = null;
          size = 0;
      }
  </code></pre>
  
  <p>I realize that clear method goes in loop for n times (Where n is number of data in Map). So I thought there can be a way to redefine that Map as <code>testMap = new HashMap&lt;String, String&gt;();</code>
  and previously used Map will be Garbage collected. </p>
  
  <p>But I am not sure this will be a good way. I am working on mobile application. </p>
  
  <p>Can you please guide me?</p>