import java.util.*;
public class MyClass {
public ArrayList list = null;
public MyClass(ArrayList list) {
this.list = list;
}
public Enumeration enum1() {
return new Enum1Impl(list);
}
//public Enumeration enum2() {
// return new Enum2Impl(list);
//}
//public Enumeration enum3() {
// return new Enum3Impl(list);
//}
private class Enum1Impl implements Enumeration {
private ArrayList list = null;
int pointer;
public Enum1Impl(ArrayList list) {
this.list = list;
if ((list == null) || (list.isEmpty())) {
pointer = -1;
}
else {
pointer = 0;
}
}
public boolean hasMoreElements() {
if (pointer == -1) {
return false;
}
if (pointer < list.size()) {
return true;
}
else {
return false;
}
}
public Object nextElement() throws NoSuchElementException {
if (pointer == -1) {
throw new NoSuchElementException("enum1");
}
if (pointer >= list.size()) {
throw new NoSuchElementException("enum1");
}
Object object = null;
if (pointer < list.size()) {
object = list.get(pointer);
pointer++;
}
return object;
}
}
}