Here you can find the source of count(Iterable iterable)
public static int count(Iterable iterable)
//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; } }