title: How to use addall in a list java
body: <p>Hello I have to add elements to my list and I notice if I Use the method add I just add the reference to my list but I would like to add the elements and not the reference:</p>
  
  <pre><code>ArrayList ArrayListIdle = new ArrayList();
  List&lt;State&gt; arrayState = new ArrayList&lt;State&gt;();
  
  while(rs.next){
  
  state = new State();
  
  state.updateStateArray(arrayState);//This function mods the elements of (arrayState);//This 
  state.setArrayStates(arrayState);//add a list of arrayState to the object state
  
  
  //I have a array and I want to add the element state with his arraylist(not the reference to)
  
  ArrayListIdle.addAll(state);
  
  // I tried with add , but in the next iteration the arrayState change.
  
  }
  </code></pre>