集册 Java实例教程 迭代器的大小

迭代器的大小

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

498
迭代器的大小

/*

  You may freely copy, distribute, modify and use this class as long

  as the original author attribution remains intact.  See message

  below.


  Copyright (C) 2003 Christian Pesch. All Rights Reserved.

 */

//package com.nowjava;

import java.util.*;
/*NowJava.com - 时代Java 提供*/

public class Main {

    public static int size(Iterator iterator) {

        int count = 0;

        while (iterator.hasNext()) {

            iterator.next();

            count++;

        }

        return count;

    }/** NowJava.com 提供 **/

}