The Java Hashtable has a constructor where you can specify a loadFactor. However, if the initialCapacity (n) is known, what’s the point of specifying the loadFactor?
Assuming that the size of its array of buckets (s) is constant, does the constructor Hashtable(int initialCapacity, float loadFactor)
just create a Hash Table that has more capacity than initialCapacity to ensure the correct loadFactor?
This assumption is not correct. The array of buckets is resized when necessary to ensure that the proportion of non-empty buckets is at most
loadFactor.(Note: the Javadoc states that “The initial capacity and load factor parameters are merely hints to the implementation. The exact details as to when and whether the rehash method is invoked are implementation-dependent”, so the above shouldn’t be taken as a strict guarantee. But it’s the general behavior.)