Just a small additional note:
After doing some reading, it appears that there is pretty much zero reason not to use Iterator (although the way I wrote it there is not the "ideal" version, it's the version that Janino can compile).
Using for-->next loop structures without using Iterator can cause various Bad Things to happen in certain contexts, especially where the data being checked might be changing in another thread.
For newbies, I think that using Iterator is probably the "best" way to code working through loops like these, and is almost certainly the safest- from what I've read, there is almost zero speed difference between that and simpler for-->next loop structures, while being a lot safer.
Best is in quotes because I'm still learning the vagaries of Java and may have missed something important in my reading, but it would appear there's broad consensus about that