Java ArrayList Methods
All ArrayList Methods
A list of all ArrayList 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() Add an item to the list boolean|void
addAll() Add a collection of items to the list boolean
clear() Remove all items from the list void
clone() Create a copy of the ArrayList Object
contains() Checks whether an item exist in the list boolean
ensureCapaci Increase the capacity of the list to be void
ty() able to fit a specified number of items
forEach() Perform an action on every item in the void
list
get() Return the item at a specific position in T
the list
indexOf() Return the position of the first occurrence int
of an item in the list
isEmpty() Checks whether the list is empty boolean
iterator() Return an Iterator object for Iterator
the ArrayList
lastIndexOf() Return the position of the last occurrence int
of an item in the list
listIterator() Return a ListIterator object for ListIterator
the ArrayList
remove() Remove an item from the list boolean|T
removeAll() Remove a collection of items from the list boolean
removeIf() Remove all items from the list which boolean
meet a specified condition
replaceAll() Replace each item in the list with the void
result of an operation on that item
retainAll() Remove all elements from the list which boolean
do not belong to a specified collection
set() Replace an item at a specified position in T
the list
size() Return the number of items in the list int
sort() Sort the list void
spliterator() Return a Spliterator object for Spliterator
the ArrayList
subList() Return a sublist which provides access to List
a range of this list's items
toArray() Return an array containing the list's Object[]
items
trimToSize() Reduce the capacity of the list to match Object[]
the number of items if necessary