title: loop through HashMap return value "null"
body: <p><strong>I have a hashmap in java in which I store for test:</strong></p>
  
  <pre><code>HashMap&lt;String, String&gt; hmap = new HashMap&lt;Integer, String&gt;();
  
   //add elements to HashMap
   hmap.put("1", "AA");
   hmap.put("2", "BB");
   hmap.put("3", "CC");
   hmap.put("4", "DD");
  </code></pre>
  
  <p><strong>Then I want to group my key-values by pairs</strong></p>
  
  <pre><code> for(String id1: hmap.keySet()) {
              Integer id2 = Integer.valueOf(id1)+1;
              while(id2 &lt;= 4){
                  String IDs = id1 + "/" + String.valueOf(id2);
                  String Contents = hmap.get(id1) + "/" + hmap.get(String.valueOf(id2));
                  System.out.println(IDs);
                  System.out.println(Contents);
                  id2++;
              }
          }
  </code></pre>
  
  <p><strong>But I obtain as a result:</strong></p>
  
  <pre><code>1/2
  AA/null
  1/3
  AA/null
  1/4
  AA/null
  2/3
  BB/null
  2/4
  BB/null
  3/4
  CC/null
  </code></pre>
  
  <p>While I was hoping</p>
  
  <pre><code>1/2
  AA/BB
  1/3
  AA/CC
  ...
  </code></pre>
  
  <p>The code I post is just for example. I have a HashMap with (ID, value) and I want to create a new HashMap with all pairs of ID (one time each) and pairs of value. But the hmap.get(String.valueOf(id2)) returns always a "null" value.</p>
  
  <p>Can someone explain why the second value is null and what I can do to remediate?</p>