If you look at the String.contentEquals code, you will see: public boolean contentEquals(CharSequence cs) { .... // Argument is a String if (cs.equals(this)) return true; // Argument is a generic CharSequence char v1[] = value; int n = v1.length; if (n != cs.length()) { return false; } for (int i = 0; i < n; i++) { if (v1[i] != cs.charAt(i)) { return false; } } That is, if we pass a String in, and we mismatch, we do the per-char test as the fallback, which is guaranteed to "false" again.
|