WHEN AND WHY HASHCODE OVERRIDE IN COSTUME CLASSES?

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
Java 
 896  View(s)
Ratings:
Rate this:
Why we override Hashcode in our costume classes?
  1. Mayank Tripathi

    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

  1. Mayank Tripathi

    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.

Answer

NEWSLETTER

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