What is the hashcode of a primitive type, such as int?
for example, let's say num was an interger.
int hasCode = 0; if (num != 0) { hasCode = hasCode + num.hashCode(); }
Taken from the Integer.class source code:
Integer.class
/** * Returns a hash code for this {@code Integer}. * * @return a hash code value for this object, equal to the * primitive {@code int} value represented by this * {@code Integer} object. */ public int hashCode() { return value; }
Where value is the value of the integer.
value
1.4m articles
1.4m replys
5 comments
56.9k users