Here you can find the source of count(Iterable> i)
public static int count(Iterable<?> i)
//package com.java2s; /**/*from w w w . ja v a 2 s . c o m*/ * Copyright 2009-2016 Three Crickets LLC. * <p> * The contents of this file are subject to the terms of the LGPL version 3.0: * http://www.gnu.org/copyleft/lesser.html * <p> * Alternatively, you can obtain a royalty free commercial license with less * limitations, transferable or non-transferable, directly from Three Crickets * at http://threecrickets.com */ import java.util.Iterator; public class Main { public static int count(Iterable<?> i) { int count = 0; Iterator<?> ii = i.iterator(); while (ii.hasNext()) { ii.next(); count++; } return count; } }