• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

hashCode method implementation

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider we have

Employee e1 = new Employee("TCS");
Employee e2 = new Employee("GS");
Employee e3 = new Employee("TCS");

where Employee is our class.

How should we implement the hashCode method so that we can have same hasCode value for objects e1 and e3.
Best Regards,
Wrushasen D.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
implementation of hashCode for above scenario is difficult as for my concern,is because Employee class not having variables to distinguish with parameterised constructor's parameter...
ofcourse return type of hashcode is int so how the int value relates to string and with that one it is different for different values.
so,if anybody can tell please...
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have posted the reply in the other post of yours in the Java(beginner) forum
Here is the link
Please dont post the same question in multiple forums.
 
reply
    Bookmark Topic Watch Topic
  • New Topic