If I overload equals should I still override haschode in java? -
i know should override hascode everytime override equals overloading? should still override hashcode?
side note: before posting question i've read should avoid overloading equals in first place i'd still know should if i'd choose overload it.
no hash-based collection ever use overloaded equals() method. it's method, , decide should do. contract entirely yours.
but i'll repeat said in question: shouldn't overload equals() in first place. if do, should @ least make consistent actual equals(object) method avoid confusions. , since should consistent equals(), means need override equals(object), , override hashcode().
Comments
Post a Comment