ArrayList
A mutable ordered list backed by an array that grows as elements are added.
Duplicates are retained. Nullable element types may store null. A List view refers to the same object and observes later mutations. Removed storage slots are cleared; clear retains backing capacity for reuse. Insertion and removal shift following elements.
Adding, removing, or calling clear invalidates existing iterators, except for removal through that iterator itself. set replaces an element without changing size or invalidating iterators. Allocation uses the VM heap budget.
Parameters
initial backing capacity, not the list's initial size.
Type Parameters
element type.
See also
Throws
if initialCapacity is negative.
Constructors
Properties
Functions
Returns the first element, or null when this iterable is empty.
Returns the first element, or null when this list is empty.
Returns the first matching element, or null when no element matches predicate.
Checks whether this collection contains at least one element.
Creates a new mutable iterator that visits this list in index order.
Returns the last index whose element equals element, or -1 when no match exists.
Returns the last element, or null when this iterable is empty.
Returns the last element, or null when this list is empty.
Returns the last matching element after traversing this iterable in iteration order.
Returns the last element satisfying predicate, or null when no element matches.
Appends non-null transformed elements to destination in iteration order.
Numeric accumulation traverses once in iteration order without an intermediate collection. Empty iterables return positive numeric zero. Integer arithmetic wraps at the result width; Float/Double addition retains ordinary rounding, infinities and NaN. Byte/Short widen to Int; UByte/UShort widen to UInt. Iterator failures propagate unchanged.
Sums selector once per element in iteration order, returning Double zero when empty. No collection is allocated; selector/iterator exceptions and inline non-local returns propagate. Addition retains ordinary Double rounding, infinities and NaN.
Sums selector once per element in iteration order, returning Int zero when empty. No collection is allocated; selector/iterator exceptions and inline non-local returns propagate. Addition uses ordinary wrapping Int arithmetic.
Sums selector once per element in iteration order, returning Long zero when empty. No collection is allocated; selector/iterator exceptions and inline non-local returns propagate. Addition uses ordinary wrapping Long arithmetic.
Sums selector once per element in iteration order, returning UInt zero when empty. No collection is allocated; selector/iterator exceptions and inline non-local returns propagate. Addition uses ordinary wrapping UInt arithmetic.
Sums selector once per element in iteration order, returning ULong zero when empty. No collection is allocated; selector/iterator exceptions and inline non-local returns propagate. Addition uses ordinary wrapping ULong arithmetic.