SE450
:
Factory Methods
[19/55]
Every collection can produce an iterator
Iterator iter = list.iterator()
Why not use constructors?
Iterator iter = new LinkedListIterator(list);
Drawback: not generic
Collection coll = ...;
Iterator iter = new ???(coll);
Factory method works for all collections
Iterator iter = coll.iterator();
Polymorphism!