What is Iterator and collections? Does these two have any relations?
// the interface definition
Interface Iterator {
boolean hasNext();
Object next();
Technically iterators and collections are not directly related. However Iterators are mostly used together with collections to interate over the objects contained in the collection.
Iterators are a general and flexible concept that allows to interate objects without depending on the exact implementation of the entity that they iterate over.