Java examples for Collection Framework:Iterator
size of Iterator
/*/* w w w . j a va 2 s . co m*/ You may freely copy, distribute, modify and use this class as long as the original author attribution remains intact. See message below. Copyright (C) 2003 Christian Pesch. All Rights Reserved. */ //package com.java2s; import java.util.*; public class Main { public static int size(Iterator iterator) { int count = 0; while (iterator.hasNext()) { iterator.next(); count++; } return count; } }