title: Why does the value change outside of the method?
body: <p>I have this code : </p>
  
  <pre><code>private MyClass myMethod(HashMap&lt;MyEnum, String&gt; preferences, String type){
  // stuff 
  preferences.put(MyEnum.enum, type); 
  MyClass myClass = ExtractMyClass(preferences);
  return myClass; 
  }
  </code></pre>
  
  <p>I call this method here : </p>
  
  <pre><code>public List&lt;MyClass&gt; myBigClass(){
  List&lt;MyClass&gt; myList = new ArrayList&lt;&gt;();
  //do a lot of stuff
  Map&lt;MyEnum, String&gt; preferences = new HashMap&lt;&gt;();
  preferences.put(MyEnum.enum, "value0");
  
  myList.add(myMethod(preferences, "value1")); //first call
  myList.add(myMethod(preferences, "value2")); //second call
  myList.add(myMethod(preferences, "value3")); //third call
  
  return myList; 
  
  }
  </code></pre>
  
  <p>In the first call, <code>preferences</code> contains only <code>value0</code> </p>
  
  <p>In the second call, it contains <code>value0</code>" and <code>value1</code></p>
  
  <p>And in the third call, it has <code>value0</code>, <code>value1</code> and <code>value2</code></p>
  
  <p>I want that, for the three calls, <code>preferences</code> should have only <code>value0</code> </p>
  
  <p>Why does the other values stay there, even though it was added inside a method ?</p>