I am having trouble understanding this error. Error message: Exception in thread "main" java.util.ConcurrentModificationException
public static int lift(List<String> list) {
int index = 0;
for (String element : list) {
list.remove(index);
list.add(index, element.toUpperCase());
index++;
}
I'm trying to replace list items but I guess removing and adding in the same iteration is considered a concurrent modification? Is that right? I tried element = element.toUppercase() but that wasn't actually modifying the list at all...
Please help! I am a beginner (obviously)