Please look at the Joshua Bloch Effective Java link .
In the second paragraph, the author says:
The class is private or package-private, and you are sure that its equals method will never be called. Perhaps the equals method should be overridden in these circumstances if it is accidentally called:
@Override public boolean equals(Object o) { throw new AssertionError();
Please explain this. I am confused by the fact that the author uses the term private class, and why there is a need to override the equals method if we know for sure that it will not be called.
java equals effective-java
user961690
source share