title: What's the difference between java.util.Map.putAll(Map<>) and java.util.Map.put(Integer, Object) in a loop
body: <p>In the code below, I found that using the putAll method can cause problems if we pass the map in parameter</p>
  
  <pre><code>public class Main {
  
      public static void main(String...strings ) {
          Etudiant e1=new  Etudiant(5, "A");
          Etudiant e2=new  Etudiant(6, "B");
  
          Map&lt;Integer, Etudiant&gt; map= new HashMap&lt;&gt;();
          map.put(1, e1);
          map.put(2, e2);
  
          Map&lt;Integer, Etudiant&gt; map2= new HashMap&lt;&gt;();
          map2.put(1,map.get(1));
          map2.put(1,map.get(2));
  
          changeMe(map2);
          System.out.println(map.get(1));
  
          Map&lt;Integer, Etudiant&gt; map3= new HashMap&lt;&gt;();
          map3.putAll(map);
          changeMe(map3);
          System.out.println(map.get(1));
      }
  
      private static void changeMe(Map&lt;Integer, Etudiant&gt; etudiants) {
          etudiants.get(1).name="K";
      }
  }
  }
  </code></pre>
  
  <p>Here is the ouput result:</p>
  
  <pre><code>Etudiant [age=5, name=A]
  Etudiant [age=5, name=K]
  </code></pre>
  
  <p>Could you explain the difference ?</p>
  
  <p>Why after the use of putAll the object changes ?</p>