I am currently studying the interface Comparatorand noticed that the documentation for Comparator equals the method, it indicates
Note that it is always safe not to override Object.equals (Object)

I checked the equalsdefault implementation of the method in the classObject

Thus, when using the equalsdefault method , it simply checks to see if two instances point to the same object, because it this == objchecks reference equality.
But what happens if I have two instances Comparator, the result they return is identical, and I want to know if they are equivalent. If I do not override the default method Object equals, then regardless of whether the result they return is equivalent or not, using the Object equalsdefault method will always be returned false. Is it still always safe not to override Object.equals (Object) ?
source
share