public class CompoundIterator extends Object implements Iterator
Iterator interface and combines two
Iterator objects into one single Iterator.
The constructor takes two Iterator arguments: parent
and child. Calling next() on this Iterator
will first try to return an element from the parent Iterator
and once the parent Iterator does not have any more elements
it will return elements from the child Iterator.
| Constructor and Description |
|---|
CompoundIterator(Iterator parent,
Iterator child)
Creates a
CompoundIterator based on parent
and child. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Returns
true if either parent or child iterator
has a next element; false otherwise. |
Object |
next()
Returns the next element from the parent or the child
iterator object.
|
void |
remove()
Always throws
UnsupportedOperationException |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic CompoundIterator(Iterator parent, Iterator child)
CompoundIterator based on parent
and child. This CompountIterator will first
return elements from parent and then elements from
child.parent - the Iterator from where to return the elements
first.child - the Iterator from where to return the elements
after parent does not have elements any more.public boolean hasNext()
true if either parent or child iterator
has a next element; false otherwise.public Object next()
public void remove()
throws UnsupportedOperationException
UnsupportedOperationExceptionremove in interface IteratorUnsupportedOperationException - always!Copyright © 2010 - 2020 Adobe. All Rights Reserved