Be aware, it is not a duplicate of Why start an ArrayList with an initial capacity?
Looking into the source code of the java.util.ArrayList
class, starting from at least java 1.8 I see the following code:
/**
* Constructs an empty list with an initial capacity of ten.
*/
public ArrayList() {
this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
}
Where
private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {};
Though the javadoc officially states:
Constructs an empty list with an initial capacity of ten.
I outline: ...an initial capacity of ten. Where is this ten?
Am I completely mad and missing something, or there is simply a javadoc bug here?
UPD: How it looked like prior java 1.8:
public ArrayList(int initialCapacity) {
super();
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal Capacity: "+
initialCapacity);
this.elementData = new Object[initialCapacity];
}
/**
* Constructs an empty list with an initial capacity of ten.
*/
public ArrayList() {
this(10);
}