previous |
start |
next
Hashing
- hashCode method used in HashMap,
HashSet
- Computes an int
from an object
- Example: hash code of String
int h = 0;
for (int i = 0; i < s.length(); i++)
h = 31 * h + s.charAt(i);
- Hash code of "eat"
is 100184
- Hash code of "tea"
is 114704
previous |
start |
next