Why does CopyOnWriteArrayList use getArray () to access an array reference?

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);
}
+6
source share

All Articles