Source Code : ArrayEnumeration class (implements Enumeration)
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
ArrayEnumeration class (implements Enumeration)

import java.lang.reflect.Array;
import java.util.Enumeration;
public class ArrayEnumeration implements Enumeration {
private final int size;
private int cursor;
private final Object array;
public ArrayEnumeration(Object obj) {
Class type = obj.getClass();
if (!type.isArray()) {
throw new IllegalArgumentException("Invalid type: " + type);
}
size = Array.getLength(obj);
array = obj;
}
public boolean hasMoreElements() {
return (cursor < size);
}
public Object nextElement() {
return Array.get(array, cursor++);
}
public static void main(String args[]) {
Object obj = new int[] { 2, 3, 5, 8, 13, 21 };
ArrayEnumeration e = new ArrayEnumeration(obj);
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
}
try {
e = new ArrayEnumeration(ArrayEnumeration.class);
} catch (IllegalArgumentException ex) {
System.out.println(ex.getMessage());
}
}
}
Thank with us