Sitemap

ArrayList in Java

1 min readJun 2, 2026

--

Many programmers know what an ArrayList is but don’t know the details about it, so I will tell you the detailed internal work of ArrayList, its complexity, and how we can use it in real-time enterprise applications.

First of all, ArrayList is a dynamically resizable array implementation in Java. ArrayList is not a special dynamic data structure. Internally, it uses an array (Object[]) and increases its capacity when needed.

e.g., ArrayList<String> list = new ArrayList<>();

If we want to get the list or add a list or remove it, we can use methods like add(), get(), remove(), and contains().

Its time complexity is O(1) to get a list, but when we talk about adding or removing the element, then its time complexity will change to O(n) because whenever we have to insert or remove the element, then internally the array has to shift each element in the array.

For real-time projects, we can use

Get Sonu Diwse’s stories in your inbox

Join Medium for free to get updates from this writer.

Fetching employees from DB:

List<Employee> employees =
employeeRepository.findAll();

Store in:

ArrayList<Employee>

Process:

for (Employee emp : employees) {
System.out.println(emp.getName());
}

This is how ArrayList is commonly used in Spring Boot and enterprise applications.

--

--