title: Hashmap not showing previously added strings
body: <p>I am working on adding a <code>String</code> key and <code>String</code> value to a <code>hashmap1</code>. In turn, I also have to add that <code>hashmap1</code> to another <code>hashmap2</code> as a value whose key is a <code>String</code>. </p>
  
  <p>Somehow, the <code>hashmap1</code> is overwriting the values for all the keys with the last added value. How do I resolve this to get <code>hashmap1</code> which contains all the value pairs that I added. <code>Al</code> is an <code>ArrayList</code> which contains the values that I am adding to the <code>hashmap1</code>.</p>
  
  <pre><code>    al.add("def");
      al.add("xyz");
      al.add("pqr");
      al.add("mno");  
      for(int i=0; i&lt;al.size();i++){
          map.put("positionTitle", al.get(i).toString());
          System.out.println(map.get("positionTitle"));
          positionTitles.put(String.valueOf(i), map);
          System.out.println("Value in the position title while in the loop "+positionTitles.get(String.valueOf(i)).get("positionTitle"));
      }
  
      for(String s: positionTitles.keySet()){
          System.out.println("key in the position title:" +s);
          for(String a: positionTitles.get(s).keySet()){
          System.out.println("Keys in the map in the position title "+a);
          System.out.println("Values in the map in position title "+positionTitles.get(s).get(a));
          }
      }
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>[abc, def, xyz, pqr, mno]</p>
    
    <p>abc</p>
    
    <p>Value in the position title while in the loop abc</p>
    
    <p>def</p>
    
    <p>Value in the position title while in the loop def</p>
    
    <p>xyz</p>
    
    <p>Value in the position title while in the loop xyz</p>
    
    <p>pqr</p>
    
    <p>Value in the position title while in the loop pqr</p>
    
    <p>mno</p>
    
    <p>Value in the position title while in the loop mno</p>
    
    <p>key in the position title:0</p>
    
    <p>Keys in the map in the position title positionTitle</p>
    
    <p>Values in the map in position title mno</p>
    
    <p>key in the position title:1</p>
    
    <p>Keys in the map in the position title positionTitle</p>
    
    <p>Values in the map in position title mno</p>
    
    <p>key in the position title:2</p>
    
    <p>Keys in the map in the position title positionTitle</p>
    
    <p>Values in the map in position title mno</p>
    
    <p>key in the position title:3</p>
    
    <p>Keys in the map in the position title positionTitle</p>
    
    <p>Values in the map in position title mno</p>
    
    <p>key in the position title:4</p>
    
    <p>Keys in the map in the position title positionTitle</p>
    
    <p>Values in the map in position title mno</p>
  </blockquote>