When and why Hashcode override in costume classes?

Total Post:149

Points:1043
Java 
 1149  View(s)
Ratings:
Rate this:
Why we override Hashcode in our costume classes?
  1. Post:397

    Points:3117
    Re: When and why Hashcode override in costume classes?

    if u want to check object's content then you have to override equal() and hashcode(). basically hashcode() is check reference address only

      Modified On Apr-09-2018 03:45:06 AM
  1. Post:397

    Points:3117
    Re: When and why Hashcode override in costume classes?

    generally for every object contains one unique hashcode generated by jvm. 
    hashcode tells the programmer which class object it is. 

    OBJECT class produces one unique code for object. i.e, hexa decimal integer. 

    if u dont like this hexa decimal numerical value there is a chance to overridde hashcode value and whatever value give for that object then u should override hashCode() method in ur class and return it.

      Modified On Apr-09-2018 03:45:16 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!