title: Hashmap updating for all keys if value is updated for a particular key
body: <p>I've a hashmap with key as integer and value as list of dates. I'm trying to update one of the value for a particular integer. Initially the dates will be same for all keys. </p>
  
  <p>Now, I want to set one of the date as null to 101 key, when I update a particular key, its updated for all keys. Where am I doing wrong? Please suggest. </p>
  
  <p>Here is my code </p>
  
  <p>Initial the dates are set like this </p>
  
  <pre><code>   // Set dates to all records
     resultDate = [Mon Jan 01 00:00:00 IST 2018, Fri Dec 31 00:00:00 IST 9999] // Typo here 
     Set&lt;Integer&gt; records= parsedResults.keySet();
          if (records.size() &gt; 0) {               
              for (Integer record: records) {
                  dateMap.get(Integer.parseInt(record));
                  dateMap.put(record,resultDate);
              }
          }
  </code></pre>
  
  <p>Then updating end date as null only for 101</p>
  
  <pre><code>for (Map.Entry&lt;Integer, List&lt;Date&gt;&gt; entry : dateMap.entrySet()) {
              if(entry.getKey().equals(Integer.parseInt("101"))) {
                  List&lt;Date&gt; dates = entry.getValue();
                  if(null == effDate) {
                      dates.set(0, null);
                  } else {
                      dates.set(0, effDate);          
                  }
                  if(null == endDate) {
                      dates.set(1, null); 
                  } else {
                      dates.set(1, endDate);
                  }
                  dateMap.put(Integer.parseInt("101"), dates);                                        
              }
          }
  </code></pre>
  
  <p>Initial dateMap response</p>
  
  <pre><code>{101=[Mon Jan 01 00:00:00 IST 2018, Fri Dec 31 00:00:00 IST 9999], 102=[Mon Jan 01 00:00:00 IST 2018, Fri Dec 31 00:00:00 IST 9999], 103=[Mon Jan 01 00:00:00 IST 2018, Fri Dec 31 00:00:00 IST 9999]}
  </code></pre>
  
  <p>After when I update as null then,</p>
  
  <pre><code>{101=[Mon Jan 01 00:00:00 IST 2018, null], 102=[Mon Jan 01 00:00:00 IST 2018, null], 103=[Mon Jan 01 00:00:00 IST 2018, null]}
  </code></pre>