1. iterator is an iterator class, and iterable is designed to iterate by using foreach as long as the interface is implemented.
2. the iterator interface is encapsulated in iterable, and iterator iterators can be used as long as the class of the Iterable interface is implemented.
3. Collection collection, List, and set are all implementation classes of iterable, so they and their subclasses can use foreach for iteration.
4. Iterator Neutralization Core method next (), Hasnext (), remove (), are all dependent on the current position, if the collection directly implements iterator, you must include a pointer to the current iteration position. When a collection is passed between methods, the value after next () is not known because the current position is unknown. However, when implementing Iterable, each call returns an iterator from the beginning, and each iterator does not affect each other.
The above Java collection _ talking about the difference between iterable and iterator is small to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud habitat community.