Java tutorial
//package com.java2s; import java.util.*; public class Main { public static boolean iteratesEqualSequence(Iterator<?> iter1, Iterator<?> iter2) { while (iter1.hasNext()) { if (!iter2.hasNext()) return false; Object o1 = iter1.next(); Object o2 = iter2.next(); if (!o1.equals(o2)) return false; } if (iter2.hasNext()) return false; return true; } }