Android examples for java.util:Iterable
Get the size of an iterator (number of items in it).
/*/* w ww.j a v a 2 s. co m*/ ******************************************************************************* * Copyright (C) 1996-2015, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; public class Main{ /** * Get the size of an iterator (number of items in it). * @param source * @return */ public static int size(Iterator source) { int result = 0; while (source.hasNext()) { source.next(); ++result; } return result; } }