Comparing the HashMap
and Hashtable
source code in JDK 1.6, I saw the below code inside HashMap:
/**
* The default initial capacity -
This could help:
http://www.concentric.net/~Ttwang/tech/primehash.htm
Basicly, if I remember correctly, when you have a hash table with a size that is power of 2, it's easy to get a hash function based on the less relevant bits of the key.
Using a prime number (as in 11) as the size of the table, makes collision on the table rows less likely, so inserting is "cheaper".