Здравствуйте, я должен добавить элементы в свой список, и я замечаю, что если я использую метод add, я просто добавляю ссылку в свой список, но я хотел бы добавить элементы, а не ссылку:
ArrayList ArrayListIdle = new ArrayList();
List<State> arrayState = new ArrayList<State>();
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.
}