ArrayList class is one of the most used and most basic class of Collection framework. It provides interesting capabilities and is build on array.
Below are series of articles on ArrayList class. There are tons of examples to understand the concepts.
- ArrayList constructors : How to create ArrayList instances?
- public ArrayList()
- public ArrayList(int initialCapacity)
- public ArrayList(Collection<? extends E> c)
- How to add/get/set elements in ArrayList?
- boolean add(E e)
- void add(int index, E element)
- boolean addAll(Collection<? extends E> c)
- boolean addAll(int index, Collection<? extends E> c)
- E get(int index)
- E set(int index, E element)
- List<E> subList(int fromIndex, int toIndex)
- boolean retainAll(Collection<?> c)
- How to remove elements from ArrayList?
- boolean remove(Object o)
- E remove(int index)
- boolean removeAll(Collection<?> c)
- Check if elements exists in ArrayList?
- int indexOf(Object o)
- int lastIndexOf(Object o)
- boolean contains(Object o)
- boolean containsAll(Collection<?> c)
- MISC Methods
- size()
- isEmpty()
- clear()
- hashCode()
- equals()
- trimToSize()
- toArray methods
- toArray()
- toArray(T[] a)
- Java 9 onwards methods
- default void replaceAll(UnaryOperator<E> operator)
- default void sort(Comparator<? super E> c)
- default Spliterator<E> spliterator()
- static <E> List<E> of()
- static <E> List<E> of(E e1)
- static <E> List<E> of(E e1, E e2)
- static <E> List<E> of(E e1, E e2, E e3)
- static <E> List<E> of(E e1, E e2, E e3, E e4)
- static <E> List<E> of(E e1, E e2, E e3, E e4, E e5)
- static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6)
- static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7)
- static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
- static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)
- static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10)
- static <E> List<E> of(E… elements)
- static <E> List<E> copyOf(Collection<? extends E> coll)
- Other methods that are common to Collection interface
- default boolean removeIf(Predicate<? super E> filter)
- default <T> T[] toArray(IntFunction<T[]> generator)
- default Spliterator<E> spliterator()
- default Stream<E> stream()
- default Stream<E> parallelStream()
- Serialize and DeSerialize ArrayList