title: HashMap Overwriting
body: <p>I have written the following :</p>
  
  <pre><code>HashMap&lt;String, String&gt; formMappingData= new HashMap&lt;String, String&gt;();
  HashMap&lt;String, HashMap&lt;String, String&gt;&gt; formData= new HashMap&lt;String, HashMap&lt;String, String&gt;&gt;();
  </code></pre>
  
  <p>When I am iterating the <code>formMappingData</code> I get to see only the values of the latest iteration and the previous iteration values are updated with the latest. </p>
  
  <p>The code as below</p>
  
  <pre><code>         for(Object formPts : data) {
  
               if( formPts instanceof Form) {
               System.out.println(" Form is found");
               Form frm = (Form) formPts;
              // String accessFrmRefs = frm.getAccessRefs();
               fID = "#"+frm.getId();
  
               System.out.println("The form id is "+ " "+ fID);
               List&lt;com.integra.PLMXML.Form.UserData.UserValue&gt; frmuserVal = frm.getUserData().getUserValue();
  
               for(com.integra.PLMXML.Form.UserData.UserValue uslVal : frmuserVal) 
               {              
                   if("dp_COMPONENT_NUMBER".equalsIgnoreCase(uslVal.getTitle())) {
                       //String parse_dp_comp = null;                      
                       String parse_dp_comp=uslVal.getValue();    
                       System.out.println("dp_component_number" +" "+ parse_dp_comp);
                       formMappingData.put("dp_COMPONENT_NUMBER", parse_dp_comp);
  
                   }
  
                   if("dp_SCALE".equalsIgnoreCase(uslVal.getTitle())) {
  
  
                      String  parse_dp_scale=uslVal.getValue();
                       System.out.println("dp_SCALE" +" "+ parse_dp_scale);
                       formMappingData.put("dp_SCALE", parse_dp_scale);
                   }
  
                   if("dp_MATERIAL".equalsIgnoreCase(uslVal.getTitle())) {
  
                       if(!uslVal.getValue().isEmpty() )
                       {
                          String parse_dp_material = uslVal.getValue();
                          System.out.println("parse_dp_material" + parse_dp_material);
                           formMappingData.put("dp_MATERIAL", parse_dp_material);
                       }else {
                           String parse_dp_material="Migrated Data";
                           System.out.println("parse_dp_material" + parse_dp_material);
                           formMappingData.put("dp_MATERIAL", parse_dp_material);
  
                       }
                   }
  
                   if("last_mod_date".equalsIgnoreCase(uslVal.getTitle())) {
  
  
  
                       if(!uslVal.getValue().isEmpty()) {
                           String parse_dp_last_mod_date=uslVal.getValue().toString();
                           System.out.println("parse_dp_last_mod_date" + parse_dp_last_mod_date);
                           formMappingData.put("parse_dp_last_mod_date", parse_dp_last_mod_date);
  
                       }else
                       {
                           String parse_dp_last_mod_date = new Date().toString();
                           System.out.println("parse_dp_last_mod_date" + parse_dp_last_mod_date);
                           formMappingData.put("parse_dp_last_mod_date", parse_dp_last_mod_date);
                       }
  
                   }
  
  
  
               if("owning_user".equalsIgnoreCase(uslVal.getTitle())) {
  
                   if(!uslVal.getValue().isEmpty()) {
                      String parse_dp_drawn=uslVal.getValue().toString();
                       System.out.println("parse_dp_drawn" + parse_dp_drawn);
                       formMappingData.put("parse_dp_drawn", parse_dp_drawn);
  
                   }else
                   {
                       String parse_dp_drawn = "Migrated Data";
                       System.out.println("parse_dp_drawn" + parse_dp_drawn);
                       formMappingData.put("parse_dp_drawn", parse_dp_drawn);
                   }
               }
  
  
  
               if("last_mod_date".equalsIgnoreCase(uslVal.getTitle())) {
  
                   if(!uslVal.getValue().isEmpty()) {
                      String parse_dp_usedon=uslVal.getValue().toString();
                       System.out.println("parse_dp_usedon" + parse_dp_usedon);
                       formMappingData.put("parse_dp_usedon", parse_dp_usedon);
  
                   }else
                   {
                       String parse_dp_usedon  = new Date().toString();
                       formMappingData.put("parse_dp_usedon", parse_dp_usedon);
                   }
               }
               //formData.put(fID, formMappingData);
           }
  
               //Add the hashmap details here
              formData.put(fID, formMappingData);
  
           }
       }`
  </code></pre>
  
  <p>Any Suggestions How do I solve this.</p>