public class ArrayIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>
Iterator| Constructor and Description |
|---|
ArrayIterator(T[] array)
Allocate a new ArrayIterator object that will
iterate over the specified array of objects.
|
ArrayIterator(T[] array,
int index)
Allocate a new ArrayIterator object that will iterate
over the specified array of objects, starting at a particular index.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getNextIndex()
Get the index of the next element to be retrieved.
|
boolean |
hasNext()
Determine whether the underlying Iterator has more
elements.
|
T |
next()
Get the next element from the underlying array.
|
T |
previous()
Get the previous element from the underlying array.
|
void |
remove()
Required by the Iterator interface, but not supported by
this class.
|
public ArrayIterator(T[] array)
array - The array over which to iteratepublic ArrayIterator(T[] array, int index)
array - The array over which to iterateindex - The index at which to startpublic int getNextIndex()
public boolean hasNext()
public T next() throws java.util.NoSuchElementException
next in interface java.util.Iterator<T>java.util.NoSuchElementException - No more elements existprevious(),
Iterator.next()public T previous() throws java.util.NoSuchElementException
java.util.NoSuchElementException - Attempt to move internal index before the first array elementnext()public void remove()
remove in interface java.util.Iterator<T>java.lang.UnsupportedOperationException - unconditionally