Sobes.tech
Junior

Tell about the methods of the ArrayList class.

sobes.tech AI

Answer from AI

add(E element): Adds an element to the end of the list. add(int index, E element): Inserts an element at the specified index. get(int index): Returns the element at the specified index. set(int index, E element): Replaces the element at the specified index with a new one. remove(int index): Removes the element at the specified index. remove(Object o): Removes the first occurrence of the specified object. size(): Returns the number of elements in the list. isEmpty(): Checks if the list is empty. contains(Object o): Checks if the list contains the specified object. indexOf(Object o): Returns the index of the first occurrence of the specified object, or -1 if not found. lastIndexOf(Object o): Returns the index of the last occurrence of the specified object, or -1 if not found. clear(): Removes all elements from the list. toArray(): Returns an array containing all the elements of the list. trimToSize(): Trims the capacity of the ArrayList to the current size.

Tell about the methods of the ArrayList class. — QA /… - sobes.tech