Please explain briefly what is an iterator?

Iterator provides a unified interface for traversing and operating collection elements. The Collection interface implements the Iterable interface.
Each collection returns an instance of the Iterator interface by implementing the iterator() method in the Iterable interface, and then iterates the elements of the collection.
One thing to note The thing is: when iterating the elements, you cannot delete the elements through the collection method, otherwise it will throw a ConcurrentModificationException exception. But you can delete it through the remove() method in the Iterator interface.

Guess you like

Origin blog.csdn.net/qq_47768542/article/details/109081446