Friday, 4 September 2015

Collection : What are different ways to iterate over a list?

We can iterate over a list in two different ways – using iterator and using for-each loop.

Using iterator is more thread-safe because it makes sure that if underlying list elements are modified, it will throw ConcurrentModificationException.

No comments:

Post a Comment