Here you can find the source of areEqual(final Iterator a, final Iterator b)
public static boolean areEqual(final Iterator a, final Iterator b)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { public static boolean areEqual(final Iterator a, final Iterator b) { while (a.hasNext() || b.hasNext()) { if (a.hasNext() != b.hasNext()) return false; if (!a.next().equals(b.next())) return false; }//from ww w . j a v a 2s . co m return true; } }