Almost all methods in CopyOnWriteArrayList use the getArray () method, which directly refers to the array. Is there a reason for this behavior? For example:
public int size() {
return getArray().length;
}
or
public int indexOf(Object o) {
Object[] elements = getArray();
return indexOf(o, elements, 0, elements.length);
}
source
share