Name: rlT66838 Date: 05/10/2000
java version "1.2.2"
HotSpot VM (1.0.1, mixed mode, build g)
Culled from the source files shipped with jdk 1.2.2 (see below), it appears that
String.equalsIgnoreCase() does not check that 'anotherString == this' as
String.equals() does before doing more intense checking.
Obviously String.equalsIgnoreCase(s, s) should return true without going into
regionMatches() which incidently also is not checking for '=='.
/**
* Compares this <code>String</code> to another <code>String</code>,
* ignoring case considerations. Two strings are considered equal
* ignoring case if they are of the same length, and corresponding
* characters in the two strings are equal ignoring case.
* <p>
* Two characters <code>c1</code> and <code>c2</code> are considered
* the same, ignoring case if at least one of the following is true:
* <ul><li>The two characters are the same (as compared by the
* <code>==</code> operator).
* <li>Applying the method {@link java.lang.Character#toUppercase(char)}
* to each character produces the same result.
* <li>Applying the method {@link java.lang.Character#toLowercase(char)
* to each character produces the same result.</ul>
*
* @param anotherString the <code>String</code> to compare this
* <code>String</code> against.
* @return <code>true</code> if the argument is not <code>null</code>
* and the <code>String</code>s are equal,
* ignoring case; <code>false</code> otherwise.
* @see #equals(Object)
* @see java.lang.Character#toLowerCase(char)
* @see java.lang.Character#toUpperCase(char)
*/
public boolean equalsIgnoreCase(String anotherString) {
return (anotherString != null) && (anotherString.count == count) &&
regionMatches(true, 0, anotherString, 0, count);
}
(Review ID: 100791)
======================================================================