Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An efficient hashcode function

Tags:

java

hashcode

I have a Employee class with many attributes. One of the attributes is employeeId which is of type int.

Can I have hascode function for Employee as follows?

int hashCode(){
    return new Integer(employeeId).hashCode();
}

Is it efficient?

like image 871
ako Avatar asked Nov 29 '22 11:11

ako


1 Answers

How about:

return employeeId;
like image 165
Mark Byers Avatar answered Dec 05 '22 16:12

Mark Byers