
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.97 KB | hits: 8 | expires: Never
How to use addall in a list java
ArrayList ArrayListIdle = new ArrayList();
List<State> arrayState = new ArrayList<State>();
while(rs.next){
state = new State();
state.updateStateArray(arrayState);//This fuction mods the elemets 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.
}
ArrayList arrayListIdle = new ArrayList();
while(rs.next){
state = new State();
List<State> arrayState = new ArrayList<State>();
state.updateStateArray(arrayState);//This fuction mods the elemets of (arrayState);//This
state.setArrayStates(arrayState);//add a list of arrayState to the object state
arrayListIdle.addAll(state);
}
while(rs.next) {
List<State> arrayState = new ArrayList<State>();
...
}