title: how and when HashMap initialize entrySet and add value into it
body: <p>I find a very magic thing, the simple code as below:</p>
  
  <pre><code>public class Demo{
      public static void main(String[] args){
          HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;();
          map.put("a", "aa");
          System.out.println("end");
      }
  }
  </code></pre>
  
  <p>after invoke</p>
  
  <pre><code>HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;();
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Lj1bZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lj1bZ.png" alt="the state of map object"></a>
  the field variable <strong>entrySet</strong> is not <em>null</em>, that is to say it have been initialize.</p>
  
  <hr>
  
  <p>Then this is my <strong>first</strong> question, when the <strong>entrySet</strong> has been initialized?
  it seemed the relevant code should be in the construct of <em>HashMap</em>, but below is the source code of this constructor </p>
  
  <pre><code> public HashMap() {
      this.loadFactor = DEFAULT_LOAD_FACTOR; // all other fields defaulted
  }
  </code></pre>
  
  <p>it seemed there dont exist code which initialize <strong>entrySet</strong>.</p>
  
  <p>and thing go on.
  after invoke </p>
  
  <pre><code>map.put("a","aa")
  </code></pre>
  
  <p>the content of field variable <em>table</em> and <em>entrySet</em> as below shot.
   <a href="https://i.stack.imgur.com/wrFKY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wrFKY.png" alt="enter image description here"></a>
  Then this is my second problem: when add this value into entrySet?
  It seemed that it should be the <em>put</em> method achieve these thing.
  and below is <em>put</em> method.</p>
  
  <pre><code>public V put(K key, V value) {
      return putVal(hash(key), key, value, false, true);
  }
  </code></pre>
  
  <p>it invoke <em>putVal</em> method and below is some code of <em>putVal</em></p>
  
  <pre><code>final V putVal(...) {
      ....
      tab[i] = newNode(hash, key, value, null);
      ....
      ++modCount;//after invoke this the entrySet is still empty
      if (++size &gt; threshold)
          resize();//this has not been executed
      afterNodeInsertion(evict);//I debug several times, sometimes before invoke this the entrySet has an Element and sometimes
      return null;
  }    
  </code></pre>
  
  <p>after invoke </p>
  
  <pre><code> ++modCount;
  </code></pre>
  
  <p>the <em>entrySet</em> is empty
  and before invoke</p>
  
  <pre><code> afterNodeInsertion(evict);
  </code></pre>
  
  <p>the entrySet has a element.
  but it seemed the code between these two line has nothing with <em>entrySet</em>.
  I think maybe there exist several threads operate <em>entrySet</em> then I write a small tool with <em>jvm_ti</em> to print the threadID which invoke the class below package <em>java.util</em> and find there is only one thread.</p>
  
  <p>Then what I miss? Does there exist issue at process of debug? Wish I have describe my problem clearly and everything would be appreciate. </p>
  
  <p><strong>add:</strong>   my java version is <em>1.8.0_77</em> and eclipse version is <em>4.6.1</em> and <em>4.5.1</em></p>