Web / Apache Commons Collections Interview questions
What is the purpose of IteratorUtils in Apache Commons Collections?
IteratorUtils is a static helper class for constructing and combining Iterator instances beyond what the JDK provides directly.
chainedIterator()- walks through several iterators back to back as onefilteredIterator()- skips elements that fail a PredicatetransformedIterator()- applies a Transformer to each element as it's returnedsingletonIterator()- wraps exactly one object as an IteratortoList()/toArray()- drains an Iterator into a concrete collection
These helpers are handy when an API only exposes an Iterator (not a full Collection), letting you still filter, transform, or combine that data without first materializing it into a List by hand.
More Related questions...