static int compareCharIterators_maxLen(CharacterIterator it1, CharacterIterator it2, int n) { for i to n: { if (!it1.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; }