What I am trying to do is to loop through a list of indices that refer to a paragraph somewhere. If there paragraph is too short, remove the index from the list.
This is the code I am using at the moment, after googling around, I tried to take the advice to use an Iterator, but still no luck.
ArrayList<Content> list = anotherList;
Iterator<Content> i = list.iterator();
while (i.hasNext()) {
Content element = i.next();
int index = list.indexOf(element);
String paragraph = getContent(index);
if (paragraph.split(" ").length < minWordCount) {
i.remove();
} else {
irrelevantFuction(index);
}
}
The iterator still seems to skip over elements if i.remove() is called, which I understood was exactly what an iterator is meant to prevent.
Could someone point out where I am going wrong?
Thanks