title: HashMap values are changing without telling them to
body: <p>I have a problem that I am unable to understand..</p>
  
  <p>I am building a <code>HashMap called wholeSetHistory</code>.</p>
  
  <p>I am building a HashMap with the same keys and values that wholeSetHistory has, called <code>wholeSetHistoryT</code>.</p>
  
  <p>In a similar way I create two <code>HashMaps called wholeSetRates, wholeSetRatesT</code></p>
  
  <p>All HashMaps have this format <code>HashMap&lt;String, HashMap&lt;String, Double&gt;&gt;</code> .</p>
  
  <p>I have this function that creates a train set</p>
  
  <pre><code>public void createTrainSet(HashMap&lt;String, HashMap&lt;String, Double&gt;&gt; wholeSetRates, HashMap&lt;String, HashMap&lt;String, Double&gt;&gt; wholeSetHistory){
      for(String fbid : wholeSetHistory.keySet()){
          ArrayList&lt;String&gt; locsBe = new ArrayList&lt;&gt;();
          HashMap&lt;String, Double&gt; locss = wholeSetHistory.get(fbid);
          HashMap&lt;String, Double&gt; locss2 = wholeSetRates.get(fbid);
          for(String loc : locss.keySet()){
              if(locss.get(loc)==1.0){
                  locsBe.add(loc);
              }
          }
          ArrayList&lt;Integer&gt; randomNums = new ArrayList&lt;&gt;();
          for(int i=0; i&lt;2; i++){
              Random rn = new Random();
              int randomNum; 
              do{
                  int range = locsBe.size() - 1 + 1;                    
                  randomNum =  rn.nextInt(range); 
              }while(randomNums.contains(randomNum));
              randomNums.add(randomNum); 
              locss.put(locsBe.get(randomNum), 0.0);
              locss2.put(locsBe.get(randomNum), 0.0);
              wholeSetHistory.put(fbid, locss);    
              wholeSetRates.put(fbid, locss2);   
          }
          randomNums.clear();
      }  
  }
  </code></pre>
  
  <p>So, later on I am using it like this</p>
  
  <pre><code>(... creation of wholeSetHistory, wholeSetHistoryT, wholeSetRates, wholeSetRatesT)
  System.out.println(wholeSetHistory.get("1"));//1
  createTrainSet(wholeSetRatings, wholeSetHistory, nearUserIDWithVisitedTrueValues);
  </code></pre>
  
  <p>That means that I am passing to the function as paramater only <code>wholeSetHistory</code></p>
  
  <p>Although, later I </p>
  
  <pre><code>System.out.println(wholeSetHistory.get("1"));//2
  System.out.println(wholeSetHistoryT.get("1"));//3
  </code></pre>
  
  <p><strong>This is what happens:</strong></p>
  
  <blockquote>
    <p>The values that changes in  wholeSetHistory changes in wholeSetHistoryT too! 
    For example, prints 2 and 3 are the same(!) and different from 1.</p>
  </blockquote>
  
  <p>Any help is mych appreciated.</p>