is hashCode() must return a prime number

Posted by subhashis on Stack Overflow See other posts from Stack Overflow or by subhashis
Published on 2010-04-22T07:59:34Z Indexed on 2010/05/20 15:30 UTC
Read the original article Hit count: 195

Filed under:
|
|

The signature of the hashCode() method is

public int hashCode(){
    return x;
}

in this case x must be an int(primitive) but plz can anyone explain it to me that the number which the hashCode() returns must be a prime number, even number...etc or there is no specification ? the reason behind i am asking this question is i have seen it in different ids the auto generated code always returns a prime number, so i need to know why?

thanks in advance

© Stack Overflow or respective owner

Related posts about hashcode

Related posts about return