Question: What are the Methods of ArrayList?

Answer: Methods of ArrayList

	
 

Method: void add(int index, E element)	
Description: It is used to insert the specified element at the specified position in a list.

Method: boolean add(E e)	
Description: It is used to append the specified element at the end of a list.

Method: boolean addAll(Collection<? extends E> c)	
Description: It is used to append 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.

Method: boolean addAll(int index, Collection<? extends E> c)	
Description: It is used to append all the elements in the specified collection, starting at the specified position of the list.

Method: void clear()	
Description: It is used to remove all of the elements from this list.

Method: void ensureCapacity(int requiredCapacity)	
Description: It is used to enhance the capacity of an ArrayList instance.

Method: E get(int index)	
Description: It is used to fetch the element from the particular position of the list.

Method: boolean isEmpty()	
Description: It returns true if the list is empty, otherwise false.

Method: Iterator() listIterator() int lastIndexOf(Object o)	
Description: It is used to return the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.

Method: Object[] toArray()	
Description: It is used to return an array containing all of the elements in this list in the correct order.

Method: <T> T[] toArray(T[] a)	
Description: It is used to return an array containing all of the elements in this list in the correct order.

Method: Object clone()	
Description: It is used to return a shallow copy of an ArrayList.

Method: boolean contains(Object o)	
Description: It returns true if the list contains the specified element.

Method: int indexOf(Object o)	
Description: It is used to return the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element.

Method: E remove(int index)	
Description: It is used to remove the element present at the specified position in the list.

Method: boolean remove(Object o)	
Description: It is used to remove the first occurrence of the specified element.

Method: boolean removeAll(Collection<?> c)	
Description: It is used to remove all the elements from the list.

Method: boolean removeIf(Predicate<? super E> filter)	
Description: It is used to remove all the elements from the list that satisfies the given predicate.

Method: protected void removeRange(int fromIndex, int toIndex)	
Description: It is used to remove all the elements lies within the given range.

Method: void replaceAll(UnaryOperator<E> operator)	
Description: It is used to replace all the elements from the list with the specified element.

Method: void retainAll(Collection<?> c)	
Description: It is used to retain all the elements in the list that are present in the specified collection.

Method: E set(int index, E element)	
Description: It is used to replace the specified element in the list, present at the specified position.

Method: void sort(Comparator<? super E> c)	
Description: It is used to sort the elements of the list on the basis of the specified comparator.

Method: Spliterator<E> spliterator()	
Description: It is used to create a spliterator over the elements in a list.

Method: List<E> subList(int fromIndex, int toIndex)	
Description: It is used to fetch all the elements that lies within the given range.

Method: int size()	
Description: It is used to return the number of elements present in the list.

Method: void trimToSize()	
Description: It is used to trim the capacity of this ArrayList instance to be the list's current size.