public class ArrayIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>
ArrayIterator class iterates over an array.| Constructor and Description |
|---|
ArrayIterator(E[] array)
Constructs an
ArrayIterator from an array of Objects. |
ArrayIterator(E[] array,
int startIndex)
Constructs an
ArrayIterator from an array of Objects and an inclusive beginning index. |
ArrayIterator(E[] array,
int startIndex,
int endIndex)
Constructs an
ArrayIterator from an array of Objects, an inclusive start index, and an exclusive end index. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Returns
true if there are more elements in the
array; otherwise false. |
E |
next()
Returns the next
Object from the array. |
void |
remove()
Unsupported: if support were to be added, it should be disabled by
default.
|
public ArrayIterator(E[] array)
ArrayIterator from an array of Objects.array - the array of Objects over which to iteratepublic ArrayIterator(E[] array, int startIndex)
ArrayIterator from an array of Objects and an inclusive beginning index. The iterator will return all
elements from the beginning index to the end of the array.array - the array of Objects in which to iteratestartIndex - the index of the first element to return.public ArrayIterator(E[] array, int startIndex, int endIndex)
ArrayIterator from an array of Objects, an inclusive start index, and an exclusive end index. The
iterator will return all elements from the start index up to (but not
including) the end index.array - the array of Objects over which to iteratestartIndex - the index of the first element to return.endIndex - the index of the element following the last element to return.public boolean hasNext()
true if there are more elements in the
array; otherwise false.hasNext in interface java.util.Iterator<E>public E next()
Object from the array.next in interface java.util.Iterator<E>public void remove()
remove in interface java.util.Iterator<E>