(I believe this is not a duplicate question!!). I am trying to iterate over a arrayList, do some manipulation and add elements to the same arrayList inside the for each loop.
I want to see the results while iterating.
I am ending up with ConcurrentModification Exception.
for(String ex55 : firstListOfOptions)
{
Criteria crteria4 = session.createCriteria(Delays.class)
.add(Restrictions.eq("programName", ex55));
List<Delays> delaysList = crteria4.list();
for(Delays dlys : delaysList)
{
if(!dlys.getProgramCalls().contentEquals(" "))
{
System.out.println(dlys.getProgramCalls());
String[] resultSet = dlys.getProgramCalls().split(",");
for(String rs : resultSet)
{
firstListOfOptions.add(rs);
}
}
}
}
How do I avoid this issue. Many thanks!