Why is the initialCapacity of Hashtable 11 while the DEFAULT_INITIAL_CAPACITY in HashMap is 16 and requires a power of 2?
Comparing the HashMap and Hashtable source code in JDK 1.6, I saw the below code inside HashMap: /** * The default initial capacity - MUST be a power of two. */ static final int DEFAULT_INITIAL_CAPACITY = 16; int capacity = 1; while (capacity < initialCapacity) capacity <<= 1; However, in Hashtable, I saw this: table = new Entry[initialCapacity]; public Hashtable() { this(11, 0.75f); } So my question is: Why does HashMap require a power of 2 as the initial capacity, while Hashtable chooses 11 as the default initial capacity? I assume this has nothing to do with the thing that Hashtable is