I have a little problem. I'm trying to remove an object from ArrayList, but the change doesn't occur.
Here is the code sample:
List<Room> rooms = new CopyOnWriteArrayList<Room>();
rooms.addAll(fp.getRooms());
int counter = 1;
for(Room r: rooms){
for(Square s: r.getDoor()){
r.getDoor().remove(s);
String name = String.valueOf(fp.getRooms().size() + counter);
Room doorRoom = new Room(name, false, s, s);
rooms.add(doorRoom);
counter++;
}
}
fp.setRooms(rooms);
I'm trying to remove the object s and replace it with a new object doorRoom.
Output:
First> [S: 11:7; true, S: 11:15; true, S: 11:20; true] Second> [S: 11:7; true, S: 11:15; true, S: 11:20; true]
And I'm expecting:
First> [S: 11:7; true, S: 11:15; true, S: 11:20; true] Second> [S: 11:15; true, S: 11:20; true]
an so on...
What is the problem?
Thank you and I'll be glad to receive your response!