I was reading java.lang.String equals ignore case implementation and trying figure out why is there a lower case compare after upper case is already compared? Are there languages where this matters ,where upper cases may not match but lower cases may match?
// Code from java.lang.String class
public boolean regionMatches(boolean paramBoolean, int paramInt1, String paramString, int paramInt2, int paramInt3) {
char[] arrayOfChar1 = this.value;
int i = paramInt1;
char[] arrayOfChar2 = paramString.value;
int j = paramInt2;
if (paramInt2 < 0 || paramInt1 < 0 || paramInt1 > this.value.length - paramInt3 || paramInt2 > paramString.value.length - paramInt3)
return false;
while (paramInt3-- > 0) {
char c1 = arrayOfChar1[i++];
char c2 = arrayOfChar2[j++];
if (c1 == c2)
continue;
if (paramBoolean) {
char c3 = Character.toUpperCase(c1);
char c4 = Character.toUpperCase(c2);
// Why is java comparing to Lower case here
if (c3 == c4 || Character.toLowerCase(c3) == Character.toLowerCase(c4))
continue;
}
return false;
}
return true;
}