I have a HashMap that stores Id as key and an ArrayList as value. For a particular key, I want to get the corresponding ArrayList and manipulate one of the element of IEntity type inside that ArrayList.
My question is, as I update the property of element, would that be reflected in the ArrayList inside the HashMap as well? Or will I have to remove the list, replace that element in the list and again insert the list for that key to see the reflected value in the HashMap. I know that Java is pass by value, but its a little difficult to get my head around this scenario.
Below is the code I have. Thanks
ArrayList<IEntity> list = myMap.get(id);
Iterator<IEntity> itr = list.iterator();
while(itr.hasNext()){
IEntity element = itr.next();
if(element.checkSomeProperty() == false){
element.setThatProperty(true);
// will above statement reflect the change in ArrayList stored in HashMap as well?
}
}