Kasun Wixkramanayake wrote:I couldnt understand what is meant by symmetry and One-way interoperability
Symmetry means that if X and Y are both non-null, then X.equals(Y) must return the same results as Y.equals(X). The CaseInsensitiveString class violates that.
It looks like "one-way interoperability" basically refers to the specific manner in which it is violating symmetry. By using that instanceof test, CaseInsensitiveString.equals(String) can be true, but String.equals(CaseInsensitiveString) can never be true.
Joined: Oct 13, 2005
Yesterday, I wrote: . . . Is that a quote from Joshua Bloch’s book? . . .
It is on page 35 in the 2nd edition of Effective Java.