title: How to add objects in an ArrayList multiple times
body: <p>I add the details of a <code>Person</code> to an <code>ArrayList</code> twice, but when I want to print the two objects, it just repeats the final details twice (and it does not print the first).</p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Arraylist
  {
      Person person = new Person();
  
      ArrayList&lt;Person&gt; array = new ArrayList&lt;&gt;();
  
      Person personTwo;
      Person personThree;
      void dataEntery(String name , int age , double marks, int itc, int pf)
      {
          person.addDetail(name,age,marks);
          person.marksDetail(itc,pf);
  
          array.add(person);
      }
  
      void print()
      {
          int index =0;
          while(index&lt;array.size()) {
              personTwo = array.get(index);
              System.out.println(personTwo.name);
              System.out.println(personTwo.age);
              System.out.println(personTwo.marks);
              System.out.println(personTwo.itc);
              System.out.println(personTwo.pf);
              index++;
          }
      }
  }
  </code></pre>
  
  <p>Can anyone explain why the first isn't printing and why the last prints twice?</p>