Here you can find the source of countIterator(Iterator> it)
public static int countIterator(Iterator<?> it)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { public static int countIterator(Iterator<?> it) { int x = 0; while (it.hasNext()) { it.next();/*from w w w .j a v a 2 s . c om*/ x++; } return x; } }