

Methods are fail-fast: if the ArrayList is structurally modifiedĪt any time after the Iterator is created, in any way except through the The Iterators returned by ArrayList's iterator and listIterator List list = Collections.synchronizedList(new ArrayList(.)) To prevent accidental unsynchronized access to the ArrayList: If no such objectĮxists, the ArrayList should be "wrapped" using theĬollections.synchronizedList method. Object that naturally encapsulates the ArrayList. Modification.) This is typically accomplished by synchronizing on some That adds or deletes one or more elements, or explicitly resizes theīacking array merely setting the value of an element is not a structural (A structural modification is any operation The threads modifies the ArrayList structurally, it must be Multiple threads access an ArrayList concurrently, and at least one of Note that this implementation is not synchronized. This may reduce the amount of incremental reallocation. An application can increase the capacity of an ArrayList beforeĪdding a large number of components using the ensureCapacity Specified beyond the fact that adding an element to an ArrayList hasĬonstant amortized cost, that is, adding n elements requires O(n) As elements are added an ArrayList, itsĬapacity grows automatically. Size of the array used to store the elements in the List. TheĬonstant factor is low compared to that for LinkedList.Įach ArrayList has a capacity. The ArrayList to exceed its capacity, in which case it runs in linear time.Īll of the other operations run in linear time (roughly speaking). The add() operation runs in constant time unless it causes The size, isEmpty, get, set, iterator, and listIterator operations run inĬonstant time. (ArrayList is roughly equivalent to Vector, except that it is To manipulate the size of the array that is used internally to store the

InĪddition to implementing the List interface, ArrayList provides methods Optional List operations, and permits all elements, including null. Resizable-array implementation of the List interface. Public class ArrayList extends AbstractList implements List, Cloneable, Serializable
