Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hashCode method implementation

 
wrushasen dakhane
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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.
 
rajesh ssh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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...
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic