public class ArrayIterator
extends java.lang.Object
implements java.util.Iterator
Iterator
over an array of objects.Constructor and Description |
---|
ArrayIterator()
Construct an ArrayIterator.
|
ArrayIterator(java.lang.Object array)
Construct an ArrayIterator that will iterate over the values in the
specified array.
|
ArrayIterator(java.lang.Object array,
int start)
Construct an ArrayIterator that will iterate over the values in the
specified array.
|
ArrayIterator(java.lang.Object array,
int start,
int end)
Construct an ArrayIterator that will iterate over the values in the
specified array.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getArray()
Retrieves the array that this iterator is iterating over.
|
boolean |
hasNext()
Returns true if there are more elements to return from the array.
|
java.lang.Object |
next()
Returns the next element in the array.
|
void |
remove()
Throws
UnsupportedOperationException . |
void |
setArray(java.lang.Object array)
Changes the array that the ArrayIterator should iterate over.
|
public ArrayIterator()
setArray(Object)
is
called to establish the array to iterate over.public ArrayIterator(java.lang.Object array)
array
- the array to iterate over.java.lang.IllegalArgumentException
- if array
is not an
array.java.lang.NullPointerException
- if array
is null
public ArrayIterator(java.lang.Object array, int start)
array
- the array to iterate over.start
- the index to start iterating at.java.lang.IllegalArgumentException
- if array
is not an
array.java.lang.NullPointerException
- if array
is null
public ArrayIterator(java.lang.Object array, int start, int end)
array
- the array to iterate over.start
- the index to start iterating at.end
- the index to finish iterating at.java.lang.IllegalArgumentException
- if array
is not an
array.java.lang.NullPointerException
- if array
is null
public java.lang.Object getArray()
null
if
the no-arg constructor was used and setArray(Object)
has never
been called with a valid array.public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next()
next
in interface java.util.Iterator
java.util.NoSuchElementException
- if all the elements in the array
have already been returnedpublic void remove()
UnsupportedOperationException
.remove
in interface java.util.Iterator
java.lang.UnsupportedOperationException
- alwayspublic void setArray(java.lang.Object array)
getArray()
to "reset"
the iterator to the beginning of the array:
ArrayIterator iterator = ... ... iterator.setArray(iterator.getArray());Note: Using i.setArray(i.getArray()) may throw a NullPointerException if no array has ever been set for the iterator (see
getArray()
)array
- the array that the iterator should iterate over.java.lang.IllegalArgumentException
- if array
is not an
array.java.lang.NullPointerException
- if array
is null
Copyright © 2001-2004 Apache Software Foundation. Documenation generated April 29 2013.