As a good practice, yes, since equals , hashCode and compareTo have close values. They can be considered as different aspects of the same thing. If you mind being used elsewhere without implementing them together, you may encounter unpredictable behavior.
For example, you passed your object to a third-party library that uses a binary search algorithm, uses compareTo . A few months later, the new version of the library changed to a hashed data structure to improve performance, which are relayed to equals and hashCode . From their point of view, this does not violate the changes.
As in this case, no, because DelayQueue does not use them.
Jeffrey zhao
source share