Please look at this link of Joshua Bloch's Effective Java.
In second paragraph, the author says:
The class is private or package-private, and you are certain that its equals method will never be invoked. Arguably, the
equals
method should be overridden under these circumstances, in case it is accidentally invoked:@Override public boolean equals(Object o) { throw new AssertionError(); // Method is never called }
Please explain this. I am getting confused by the author's use of term private class and that why is there a need to override equals method when we know for certain that it won't be invoked.