Here you can find the source of iterableSize(Iterable
Iterable
.
public static <E> int iterableSize(Iterable<E> itrbl)
//package com.java2s; // Licensed under the Modified BSD Licence; see COPYING for details. import java.util.Iterator; public class Main { /** Computes, in linear time, the length of an <code>Iterable</code>. This is done by iterating over all elements from <code>itrbl</code> and counting their number. */ public static <E> int iterableSize(Iterable<E> itrbl) { int size = 0; for (Iterator<E> iter = itrbl.iterator(); iter.hasNext();) { iter.next();/* w w w. j a va2 s . c o m*/ size++; } return size; } }