I want to avoid getting ConcurrentModificationException. How would I do it?
ConcurrentModificationException
Instead of using an iterator, you can use a for loop with an index. For example:
int originalLength = list.length(); for (int i = 0; i < originalLength; i++) { MyType mt = list.get(i); //... processing //... insertions }