Java tutorial
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.util.Enumeration; import java.util.Iterator; public class Main { /** * Returns an iterable as an enumeration (some older library code excepts * these) * @param iterable the iterable * @return an enumeration returning the same sequence of elements as the * parameter iterable * @precondition iterable != null * @postcondition result != null */ public static <T> Enumeration<T> asEnumeration(final Iterable<T> iterable) { final Iterator<T> it = iterable.iterator(); return new Enumeration<T>() { @Override public boolean hasMoreElements() { return it.hasNext(); } @Override public T nextElement() { return it.next(); } }; } }