Documentation says, This interface does not refine the general contracts of the equals and hashCode methods. The result of comparing two objects that implement CharSequence is therefore, in general, undefined. Each object may be implemented by a different class, and there is no guarantee that each class will be capable of testing its instances for equality with those of the other. It is therefore inappropriate to use arbitrary CharSequence instances as elements in a set or as keys in a map.
Questions:
1. Why is it necessary to refine equals and hashCode to ensure that objects of classes implementing CharSequence can be compared?
2. What does it mean by each object may be implemented by a different class? Is it referring to:
public final class A implements CharSequence{
...
...
}
public final class B implements CharSequence{
...
...
}
Class A a = new A();
Class B b = new B();
Boolean flag = (a == b); // is this what is undefined?
Why is there a special mention about this fact in this class? This can be the fate for any other interface as well.
Thanks.