Overriding equals for CopyOnWriteArraySet.add and remove
问题 I have classes like below class A { @Override public boolean equals(Object other) { return true } } Class B extends A { } Class C extends A { @Override public boolean equals(Object other) { if ((other != null) || (other instanceOf B)) return false; } } In my main() I have this following code Set<A> mySet = new CopyOnWriteArraySet<A>(); mySet.add(C); I want mySet to contain C at this point mySet.add(B); // #1 I want mySet to contain C & B at this point mySet.remove(B); // #2 I want mySet to