Hi Jesús, > String.equals already performs that instanceof comparison, > and is one of the first to be inlined by the hotspot. What I > would do is to turn it... "this.equals(cs)" instead of > "cs.equals(this)".
That's true, but given cs is a String with length equal to this, cs.equals(this) nevertheless may return false, and if (cs.equals(this)) return true; will not return. The remaining code performs the comparison a second time in this case. > [...] > Anyway, does anyone know if the > contentEquals method is actually used out there? (at least it > isn't inside the JDK source code). I use it ;-) It is useful to prevent from duplicate memory allocation in quite some cases. -- Cheers, Alex