title: Separate java object creation in each iteration
body: <pre><code>public class Test{
  
      public void setMembersValues(List list){
  
          List&lt;Member&gt;  memberList = new ArrayList&lt;Member&gt;();
  
          for(Object o : list){
  
              String[] str = o.split("\n");
  
              if(str.equalsIgnoreCase("&lt;member&gt;")){
  
                  /**I want to create separate member objects for each 
                     list iterration.But member refers same object.**/
  
                  Member member = new Member();
  
                  for(int i =0; i&lt;str.length;i++){
  
                      if(str[i].equalsIgnoreCase("&lt;member/&gt;")){
                          memberList.add(member);
                          break;
                      }else{
                          if(str[i].equalsIgnoreCase("name"))
                              member.setName(str[i].split("//")[1]);
                      }else if(str[i].equalsIgnoreCase("Address")){
                          member.setAddress(str[i].split("//")[1]);
                      }
                  }
  
              }
  
          }
      }
  }
  </code></pre>
  
  <p>There are two lists here, but only one member object is created. I want to create separate member objects for each iteration and add it to memberList. </p>
  
  <p>How can I do it, please?</p>