Here you can find the source of size(Iterator iterator)
public static int size(Iterator iterator)
//package com.java2s; import java.util.*; public class Main { public static int size(Iterator iterator) { int count = 0; while (iterator.hasNext()) { iterator.next();// w ww .jav a2 s . com count++; } return count; } }