public class iterableCount { public static int iterableCount(Iterable<?> i) { int count = 0; Iterator<?> it = i.iterator(); while (it.hasNext()) { it.next(); count++; } return count; } }