Why no concrete implementations of Iterator interface

Why no concrete implementations of Iterator interface

Answer: Implementation could have done for iterator interface but by design Collection interface extends Iterable interface which give one method interator() and return Iterator interface. Designer given flexibility to all of its concrete classes (Child classes) to implement rule base on their need.

For example: All collection classes in java.util package are fail fast and java.util.concurrent package are fail safe.

Leave a Reply

Your email address will not be published. Required fields are marked *