I am having some trouble implementing the iterator.remove()
method correctly. I am trying to use the method to remove certain strings from an ArrayList
of strings, but every time I try using an iterator (and the iterator.remove()
method), I get an error titled "Check For Comodification". I am posting my code below for reference. Appreciate the help!
Iterator<String> iter= myWords.iterator();
while(iter.hasNext()){
String current= iter.next();
for(int i=0;i<current.length();i++){
if(current.charAt(i)==mostFrequentChar){
iter.remove();
break;
}
}
}