0
What are the advantages of using iterator in linkedlists or arraylists?
2 Réponses
+ 10
You don't have to deal with iterators anymore... you can use forEach() on the collections or the enhanced for loop and the API handles the iterators internally then.
- 1
But iterators come in handy if you need to modify collection in your loop. For example if you want to remove an element while looping with iterators you can, but with foreach you get an exception.