At Oracle tutorial about collections https://docs.oracle.com/javase/tutorial/collections/interfaces/collection.html I see the following:
Use Iterator instead of the for-each construct when you need to:
1. Remove the current element. The for-each construct hides the iterator, so you cannot call remove. Therefore, the for-each construct is not usable for filtering.
2. Iterate over multiple collections in parallel.
I understand the first option 'remove current element' which is supported by iterator and not supported by for-each construct. I need clarification about the second option 'iterate over multiple collections in parallel' which can be done with iterator and not by for-each. can someone supply an example of such scenario? As far as I understand the for-each can also be nested, so one can travel on several collections in parallel.
This is not duplicate of Iterator vs For-Each and of Iterator vs for as they ask about general comparison of iterator and for-each, and I ask about the specific sentence at oracle tutorial.