Java tutorial
//package com.java2s; /* * Copyright 2011-2016 ZXC.com All right reserved. This software is the confidential and proprietary information of * ZXC.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into with ZXC.com. */ import java.util.Collection; import java.util.Enumeration; public class Main { public static <T> Enumeration<T> toEnumeration(final Collection<T> collection) { return new Enumeration<T>() { Object[] array = collection.toArray(); int index = 0; public boolean hasMoreElements() { return (index < array.length); } @SuppressWarnings("unchecked") public T nextElement() { return (T) array[index++]; } }; } }