0

I have two list and I am Retrieving data from them.

for(String s:alist) {
for(String s1:bList) {
My code
} 
} 

I am getting Java. Util.ConcurrentModification Exception when searched for it and found some solutions on stackoverflow but still I am not able to resolve it. Please help. I am getting exception on second for each loop and I followed one of the solution from stackoverflow that take a temporary list and do addAll when added all data to actual list but still not able to resolve it. After this I have my code which is working fine. I am getting exception in Retrieving through for each loop

  • You haven't provided nearly enough information about what you're doing within the loops for us to help you. Additionally, ConcurrentModificationExceptions can be due to threading - does your code operate on the same collections from multiple threads, or is this single threaded? – Jon Skeet Nov 06 '17 at 11:30
  • 1
    Don't update `alist` or `bList` in those loops. You need to use and iterator if you want. And also provide a [mcve] because this is too broad. If not already done, check the [ConcurrentModificationException when adding inside a foreach loop in ArrayList](https://stackoverflow.com/q/9806421/4391450) – AxelH Nov 06 '17 at 11:31

0 Answers0