I have this java code that iterates over ArrayList of objects and remove some records from it, but I have a ConcurrentModificationException, here is my code.
for (ServiceWorkFlowStepModel s : svcModel.getServiceModel().getWorkFlowSteps()) {
if (s.getStepOrder().equals(stepIndex + 1)) {
svcModel.getServiceModel().getWorkFlowSteps().remove(s);
}
Iterator<ActivityModel> iter = activities.iterator();
while (iter.hasNext()) {
ActivityModel am = iter.next();
if (am.getComponentModel().getComponenetId().equals(s.getComponentId())) {
iter.remove();
}
}
}