Sobes.tech
Junior

What is an ArrayList?

sobes.tech AI

Answer from AI

A dynamic array implementing the List, RandomAccess, Cloneable, Serializable interfaces. It stores elements in a contiguous memory block, providing fast index-based access, but slow addition/removal at positions other than the end.

// Example of creating an ArrayList and adding elements
ArrayList<String> names = new ArrayList<>();
names.add("Alice");
names.add("Bob");