static int compareCharIterators(Iterator i1, Iterator i2) { while true { if (!i1.hasNext()) ret it2.hasNext() ? -1 : 0; if (!it2.hasNext()) ret 1; char a = it1.next(), b = it2.next(); if (a < b) ret -1; if (a > b) ret 1; } ret 0; }