Here you can find the source of equalsIterator(Iterator> it, Iterator> it2)
public static boolean equalsIterator(Iterator<?> it, Iterator<?> it2)
//package com.java2s; /*//from w ww . j a v a2 s . c o m * Copyright (c) 2006 Rick Mugridge, www.RimuResearch.com * Released under the terms of the GNU General Public License version 2 or later. * Written: 5/09/2006 */ import java.util.Iterator; public class Main { public static boolean equalsIterator(Iterator<?> it, Iterator<?> it2) { if (it == it2) return true; while (it.hasNext() && it2.hasNext()) { if (!it.next().equals(it2.next())) return false; } return !it.hasNext() && !it2.hasNext(); } }