I'm reading the second edition of the book, page 36. I don't understand the solution to the simmetry problem:
@override public boolean equals(Object o) {
return o instanceof CaseInsensitiveString &&
((CaseInsensitiveString) o).s.equalsIgnoreCase(s);
}
If I have the CaseInsensitiveString cis= new CaseInsensitiveString("hello")
and the String s="hello"
this behaves in a non-symmetric manner, because s.equals(cis)
is true, but cis.equals(s)
is false...
What am I missing?