I have a problem with type List<Map<String, Object>>
. I defined a Map<String, Object>
variable with which include one item (size = 1) and then a clone of this variable is added in another List
. but when I read in the next step, I have a strange problem with the readed item (Map<String, Object>
) from the List
because the readed variable has a large size, even though the added variable had size 1.
Why is this happening?
List<PlacementElementByHost> Placement_Queue = new LinkedList<>();
while(...){
PlacementElementByHost first=new PlacementElementByHost(Placement_Queue.get(0));
Placement_Queue.remove(0);
PlacementElementByHost new_element=new PlacementElementByHost();
new_element.migrationMap.add(new HashMap<>(migrate));
for(...){
Placement_List.add(new PlacementElementByHost(new_element));
}
}
and when I want to read:
PlacementElementByHost first=new PlacementElementByHost(Placement_Queue.get(0));