如果我将对象永久存储在单个桶中,HashMap 容量会增加吗?

Will be HashMap capacity increased if I permanently storing objects in a single bucket?

HashMap 有:

When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets.

那么,如果我将对象永久存储在一个桶中(make hashcode() always return 0),是否会增加容量?

是的,它仍然会调整大小(参见 source code of HashMap.putVal()):

final V putVal(int hash, K key, V value, boolean onlyIfAbsent,
               boolean evict) {
    // [code left out ...]

    ++modCount;
    if (++size > threshold)
        resize();
    afterNodeInsertion(evict);
    return null;
}

据我了解,当 HashMap(不是桶)中的条目数量变得超过 capacity * loadFactor 时,桶的数量将增加两倍,因此 HashMap 将被重新散列并且条目将分布在新的桶中.