title: Objects getting copied by reference and replacing all items in ArrayList
body: <p>I understand that people have faced this issue before and I have gone through the previous posts. 
  I have an arrayList and I'm trying to add objects to it. During every add call, the same object reference is being copied. Though I have used the 'new' operator and am creating new objects. This is something basic and has worked previously when I create the object again during each iteration. 
  Any help is much appreciated. 
  Here is my code. </p>
  
  <pre><code>public List&lt;Actor&gt; readAllActors()
  {
      String selectMovie = "SELECT * from ACTOR;";
      List&lt;Actor&gt; listOfActors = new ArrayList&lt;Actor&gt;();
      try {           
          statement = conn.prepareStatement(selectMovie);
          results = statement.executeQuery(selectMovie);      
                      Actor a = new Actor();
          while (results.next())
          {                  
                         a = getActorFromResult(results);
                         listOfActors.add(new Actor(a.getId(), a.getFirstName(), a.getLastName(), a.getDateOfBirth()));                               
          }
  
      } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }       
      return listOfActors;    
  }
  
  private Actor getActorFromResult(ResultSet results) throws SQLException {
      // TODO Auto-generated method stub
  
      int id = results.getInt("id");
      String fname = results.getString("firstName");
      String lname = results.getString("lastName");
      String dob = results.getString("dateOfBirth");
  
      Actor actor = new Actor(id, fname, lname, dob );        
      return actor;
  }
  </code></pre>
  
  <p>I have tried printing the object in each iteration. It is fetching the right row from the table.. the new Actor() seems to have no effect in creating a new object reference!!</p>