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