public class ArrayEnumeration
extends java.lang.Object
implements java.util.Enumeration
When creating an ArrayEnumeration
from an array of objects
you optionally may specify the number of elements of the array that shall
admit to the ArrayEnumeration, e.g.:
will create an ArrayEnumaeration of the first two elements of the given array of objects.SomeObject[] obj = ...; ArrayEnumeration arrayEnum = new ArrayEnumeration(obj, 2);
For getting the elements of an ArrayEnumeration use the
hasMoreElements
and
nextElement
methods, as already
familiarly from the java.util.Enumeration
, e.g.:
for (; arrEnum.hasMoreElements() ; ) { System.out.println(arrayEnum.nextElement()); }
Constructor and Description |
---|
ArrayEnumeration(java.lang.Object[] array)
Creates a new ArrayEnumeration from all the elements included in the
given array of objects.
|
ArrayEnumeration(java.lang.Object[] array,
int length)
Creates a new ArrayEnumeration from the given number of elements of
the given array of objects.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreElements()
Checks if there are more elements in this ArrayEnumeration.
|
java.lang.Object |
nextElement()
Returns the next element of this ArrayEnumeration.
|
public ArrayEnumeration(java.lang.Object[] array)
array
- the arraypublic ArrayEnumeration(java.lang.Object[] array, int length)
The first length
elements of the given array will
admit to the new ArrayEnumeration.
array
- the array (not cloned)length
- how many elements to include to the ArrayEnumerationpublic boolean hasMoreElements()
hasMoreElements
in interface java.util.Enumeration
true
if there are more elements,
false
if notpublic java.lang.Object nextElement()
nextElement
in interface java.util.Enumeration