Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.97 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use addall in a list java
  2. ArrayList ArrayListIdle = new ArrayList();
  3. List<State> arrayState = new ArrayList<State>();
  4.  
  5. while(rs.next){
  6.  
  7. state = new State();
  8.  
  9. state.updateStateArray(arrayState);//This fuction mods the elemets of (arrayState);//This
  10. state.setArrayStates(arrayState);//add a list of arrayState to the object state
  11.  
  12.  
  13. //I have a array  and i want to add the element state with his arraylist(not the reference to)
  14.  
  15. ArrayListIdle.addAll(state);
  16.  
  17. // I tried with add , but in the next iteration the arrayState change.
  18.  
  19. }
  20.        
  21. ArrayList arrayListIdle = new ArrayList();
  22.  
  23.  
  24. while(rs.next){
  25.  
  26.     state = new State();
  27.     List<State> arrayState = new ArrayList<State>();
  28.  
  29.     state.updateStateArray(arrayState);//This fuction mods the elemets of (arrayState);//This
  30.     state.setArrayStates(arrayState);//add a list of arrayState to the object state
  31.     arrayListIdle.addAll(state);
  32.  
  33. }
  34.        
  35. while(rs.next) {
  36.       List<State> arrayState = new ArrayList<State>();
  37.       ...
  38.  }