title: Why does my ArrayList contain N copies of the last item added to the list?
body: <p>I'm adding three different objects to an ArrayList, but the list contains three copies of the last object I added. </p>
  
  <p>For example:</p>
  
  <pre><code>for (Foo f : list) {
    System.out.println(f.getValue());
  }    
  </code></pre>
  
  <p>Expected:</p>
  
  <pre><code>0
  1
  2
  </code></pre>
  
  <p>Actual:</p>
  
  <pre><code>2
  2
  2
  </code></pre>
  
  <p>What mistake have I made?</p>
  
  <p><sup>Note: this is designed to be a canonical Q&amp;A for the numerous similar issues that arise on this site.</sup></p>