English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Java has many ArrayList methods that allow us to use ArrayList. On this reference page, you will find all the available ArrayList methods in Java, usage examples of ArrayList methods, etc. For example, if you need to add an element to the ArrayList, please use the add() method.
Method | Description |
---|---|
add() | Insert an element into the ArrayList |
addAll() | Add all elements of the collection to the ArrayList |
clear() | Remove all elements from the ArrayList |
clone() | Copy the ArrayList |
contains() | Check if the element exists in the ArrayList |
get() | Return the element at the specified index |
indexOf() | Return the position of the specified element |
removeAll() | Remove multiple elements from the ArrayList |
remove() | Remove a single element from the ArrayList |
size() | Return the number of elements in the ArrayList |
isEmpty() | Check if the ArrayList is empty |
subList() | Return a part of the ArrayList |
set() | Replace a single element in the ArrayList |
sort() | Sort the ArrayList according to the specified order |
toArray() | Convert the ArrayList to an array |
toString() | Convert the ArrayList to a String |
ensureCapacity() | Adjust the capacity size of the ArrayList |
lastIndexOf() | Returns the last occurrence position of the element |
retainAll() | Returns the retained common elements |
containsAll() | Check if the collection is a subset of the ArrayList |
trimToSize() | Modify the capacity of the ArrayList example to the current size of the list |
removeRange() | Remove a portion of the ArrayList |
replaceAll() | Replace all elements in the ArrayList |
removeIf() | Remove elements that meet certain conditions |
forEach() | Traverse all elements of the ArrayList |
iterator() | Returns an iterator for traversing the ArrayList in a loop |