ArrayList (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements in this list
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>
- Direct Known Subclasses:
AttributeList, RoleList, RoleUnresolvedList
-
Field Summary
Fields declared in class AbstractList
protected intThe number of times this list has been structurally modified.
-
Constructor Summary
Constructors
-
Method Summary
voidInserts the specified element at the specified position in this list.
booleanAppends the specified element to the end of this list.
booleanInserts all of the elements in the specified collection into this list, starting at the specified position.
booleanAppends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.
voidAdds an element as the first element of this collection (optional operation).
voidAdds an element as the last element of this collection (optional operation).
voidclear()Removes all of the elements from this list.
clone()Returns a shallow copy of this
ArrayListinstance.booleanReturns
trueif this list contains the specified element.voidensureCapacity(int minCapacity) Increases the capacity of this
ArrayListinstance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.voidPerforms the given action for each element of the
Iterableuntil all elements have been processed or the action throws an exception.get(int index) Returns the element at the specified position in this list.
getFirst()Gets the first element of this collection.
getLast()Gets the last element of this collection.
intReturns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
booleanisEmpty()Returns
trueif this list contains no elements.iterator()Returns an iterator over the elements in this list in proper sequence.
intReturns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
Returns a list iterator over the elements in this list (in proper sequence).
listIterator(int index) Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
remove(int index) Removes the element at the specified position in this list.
booleanRemoves the first occurrence of the specified element from this list, if it is present.
booleanRemoves from this list all of its elements that are contained in the specified collection.
Removes and returns the first element of this collection (optional operation).
booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).
Removes and returns the last element of this collection (optional operation).
protected voidremoveRange(int fromIndex, int toIndex) Removes from this list all of the elements whose index is between
fromIndex, inclusive, andtoIndex, exclusive.booleanRetains only the elements in this list that are contained in the specified collection.
Replaces the element at the specified position in this list with the specified element.
intsize()Returns the number of elements in this list.
subList(int fromIndex, int toIndex) Returns a view of the portion of this list between the specified
fromIndex, inclusive, andtoIndex, exclusive.toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).
<T> T[]toArray(T[] a) Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
voidTrims the capacity of this
ArrayListinstance to be the list's current size.Methods declared in class AbstractList
booleanCompares the specified object with this list for equality.
intReturns the hash code value for this list.
Methods declared in class AbstractCollection
booleanReturns
trueif this collection contains all of the elements in the specified collection.Returns a string representation of this collection.
Methods declared in class Object
finalize, getClass, notify, notifyAll, wait, wait, waitprotected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
Methods declared in interface Collection
parallelStream, stream, toArrayReturns a possibly parallel
Streamwith this collection as its source.Returns a sequential
Streamwith this collection as its source.default <T> T[]Returns an array containing all of the elements in this collection, using the provided
generatorfunction to allocate the returned array.Methods declared in interface List
containsAll, replaceAll, reversed, sortbooleanReturns
trueif this list contains all of the elements of the specified collection.default voidReplaces each element of this list with the result of applying the operator to that element (optional operation).
Returns a reverse-ordered view of this collection.
default voidSorts this list according to the order induced by the specified
Comparator(optional operation).
-
Constructor Details
-
ArrayList
-
ArrayList
-
ArrayList
-
-
Method Details
-
trimToSize
-
ensureCapacity
-
size
-
isEmpty
-
contains
-
indexOf
-
lastIndexOf
-
clone
-
toArray
-
toArray
-
get
-
getFirst
-
getLast
-
set
-
add
-
add
-
addFirst
-
addLast
-
remove
-
removeFirst
-
removeLast
-
remove
-
clear
-
addAll
-
addAll
-
removeRange
-
removeAll
-
retainAll
-
listIterator
-
listIterator
-
iterator
-
subList
-
forEach
-
spliterator
-
removeIf
-