A list of all methods can be found in the table below.
Some methods use the type of the ArrayList’s items as a parameter or return value. This type will be referred to as T in the table.
Method |
Description |
Return Type |
add() |
Insert an item into the list. |
boolean|void |
addAll() |
Insert a collection of items into the list. |
boolean |
clear() |
Clear all items from the list. |
void |
clone() |
Make a copy of the ArrayList. |
object |
contains() |
Check if an item is present in the list. |
boolean |
ensureCapacity() |
Expand the list’s capacity to accommodate a specified number of items. |
void |
forEach() |
Execute an action on each item within the list |
void |
get() |
Retrieve the item located at a particular position within the list. |
T |
indexof() |
Provide the index of the first occurrence of an item in the list. |
int |
isEmpty() |
Determine if the list is devoid of any elements. |
boolean |
iterator() |
Provide an Iterator object for the ArrayList. |
Iterator |
lastIndex() |
Provide the index of the last occurrence of an item in the list. |
int |
listIterator() |
Provide a ListIterator object for the ArrayList. |
listIterator |
remove() |
Eliminate an item from the list. |
boolean |
removeAll() |
Eliminate a set of items from the list. |
boolean |
removeIf() |
Eliminate all items from the list that satisfy a specified condition. |
boolean |
replaceAll() |
Substitute each item in the list with the outcome of performing an operation on that item. |
void |
retainAll() |
Eliminate all elements from the list that are not part of a specified collection. |
boolean |
set() |
Eliminate all elements from the list that are not part of a specified collection. |
T |
size() |
Substitute an item at a specified position within the list. |
int |
sort() |
Retrieve the count of items present in the list. |
void |
spilterator() |
Provide a Spliterator object for the ArrayList. |
Spliterator |
subList() |
Provide a sublist that grants access to a specific range of items within this list. |
list |
toArray() |
Provide an array containing the items of the list. |
object[] |
trimTosize() |
Adjust the capacity of the list to match the number of items, if required. |
object[] |