boolean (String anotherString) { if (anotherString == null || count != anotherString.count) return false; int i = count; int x = offset; int y = anotherString.offset; while (--i >= 0) { char c1 = value[x++]; char c2 = anotherString.value[y++]; // Note that checking c1 != c2 is redundant, but avoids method calls. if (c1 != c2 && Character.toUpperCase(c1) != Character.toUpperCase(c2) && Character.toLowerCase(c1) != Character.toLowerCase(c2)) return false; } return true; }