Java Iterable Count count(Iterable iterable)

Here you can find the source of count(Iterable iterable)

Description

count

License

Apache License

Return

The count from the iterable

Declaration

public static int count(Iterable iterable) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;

public class Main {
    /**/*from   ww w  .  j a v  a2  s . co  m*/
     * @return The count from the iterable
     */
    public static int count(Iterable iterable) {
        Iterator i = iterable.iterator();
        return count(i);
    }

    public static int count(Iterator i) {
        int count = 0;
        while (i.hasNext()) {
            count++;
            i.next();
        }
        return count;
    }
}

Related

  1. count(final Iterable iterable, final int step)
  2. count(Iterable i)
  3. count(Iterable iterable)
  4. count(Iterable iterable)