集册 Java实例教程 迭代器作为枚举

迭代器作为枚举

欢马劈雪     最近更新时间:2020-01-02 10:19:05

491
迭代器作为枚举
/**from 时 代 J a v a - N o w J a v a . c o m**/

// Licensed to the Apache Software Foundation (ASF) under one

//package com.nowjava;

import java.util.Enumeration;

import java.util.Iterator;


public class Main {

    public static <T> Enumeration<T> iteratorAsEnumeration(

            final Iterator<T> it) {

        return new Enumeration<T>() {

            public boolean hasMoreElements() {

                return it.hasNext();

            }


            
展开阅读全文