harmeet saini wrote:Hi
I am very much confused regarding this " if equals is overridden should hashCode also be overridden"
I am confused coz in CertPal i found two explanations
1) Nothing can prevent a progremmer for not overriding hashCode when overiding equals
2) if equals is overridden should hashCode also be overridden
This is a conract, not a must. It doesn't create any syntatic problem wen compiling, but you'll get some logical problems, if you don't override for your own purposes. Check the equal/hashCode contracts.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|