Почему емкость ArrayList по умолчанию равна 10?

Я видел документацию по Java для ArrayList и обнаружил, что начальная емкость ArrayList равна 10.

 /**
 * Constructs an empty list with an initial capacity of ten.
 */
public ArrayList() {
this(10);
}

Я думаю, было бы разумно, если бы это была любая степень 2, но почему 10?

Я также проверил начальную емкость HashMap, и она равна 16, что имеет смысл.

/**
 * The default initial capacity - MUST be a power of two.
 */
static final int DEFAULT_INITIAL_CAPACITY = 16;

/**
 * Constructs an empty <tt>HashMap</tt> with the default initial capacity
 * (16) and the default load factor (0.75).
 */
public HashMap() {
    this.loadFactor = DEFAULT_LOAD_FACTOR;
    threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
    table = new Entry[DEFAULT_INITIAL_CAPACITY];
    init();
}

Есть ли конкретная причина, по которой число 10?

35
задан Java Riser 20 July 2014 в 04:43
поделиться