Java ArrayList is a part of the inbuilt collection framework that is used to save the dynamically sized collection of items. Arrays are fixed in size; an ArrayList grows its size automatically when new items are added to it. ArrayList is the part of the collection framework and is present in the java.util package. ArrayList inherits the AbstractList class and implements the List interface.

Important Points about ArrayList in Java

  1. It can be compared as a Vector in C++.
  2. We cannot use primitive data types like char, int, float.
  3. We always need to use wrapper classes like Integer, String, Float, etc.
  4. Java ArrayList allows us to access the list randomly.
  5. An ArrayList is the re-sizable array, also called a dynamic array. It grows its size to accept new elements and contracts the size when the elements are removed.
  6. ArrayList internally uses an array to store the elements. Just like arrays, It allows you to fetch the elements by their index.
  7. Java ArrayList allows duplicate and null values.
  8. Java ArrayList is the ordered collection. It maintains the insertion order of the elements.
  9. Java ArrayList is not synchronized. If the multiple threads try to modify the ArrayList at the same time, then the outcome will be non-deterministic. You must explicitly synchronize access to the ArrayList if multiple threads are going to change it.

#java #java arraylist #java.util #c++

Java ArrayList Example | Array List in Java Tutorial
1.45 GEEK