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

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

qt - Microsoft FTP Service 451 The parameter is incorrect -