static int lCommonPrefixOfCharIterators(CharacterIterator it1, CharacterIterator it2) { int n = 0; while true { if (!it1.hasNext() || !it2.hasNext()) ret n; char a = it1.next(), b = it2.next(); if (a != b) ret n; ++n; } } static int lCommonPrefixOfCharIterators(CharacterIterator it1, CharacterIterator it2, CharComparator comparator) { if (comparator == null) ret lCommonPrefixOfCharIterators(it1, it2); int n = 0; while true { if (!it1.hasNext() || !it2.hasNext()) ret n; char a = it1.next(), b = it2.next(); if (comparator.compare(a, b) != 0) ret n; ++n; } }