Skip to content
Java

ArrayList API Reference

Java ArrayList — resizable-array implementation of the List interface.

By EZ4Code Team

ArrayList<E>

Resizable-array implementation of the List interface. Permits null and all elements.

boolean add(E e)

Append the specified element to the end of the list.

Returns: boolean

E get(int index)

Return the element at the specified position. Throws IndexOutOfBoundsException.

Returns: E

E set(int index, E element)

Replace the element at the specified position. Returns the previous element.

Returns: E

E remove(int index)

Remove the element at the specified position. Returns the removed element.

Returns: E

int size()

Return the number of elements in the list.

Returns: int

boolean isEmpty()

Return true if the list contains no elements.

Returns: boolean

boolean contains(Object o)

Return true if the list contains the specified element (uses equals).

Returns: boolean

int indexOf(Object o)

Return the index of the first occurrence of o, or -1 if not found.

Returns: int

void clear()

Remove all elements from the list.

Returns: void

Object[] toArray()

Return an array containing all elements in the list in proper sequence.

Returns: Object[]

More Java API References