An ArrayList is a resizable array implementation of the List interface. It allows for dynamic resizing, meaning that the size of the array can grow or shrink as elements are added or removed. ArrayLists provide fast random access to elements, as they are stored in contiguous memory locations, making it efficient to retrieve elements by their index. However, inserting or deleting elements, especially in the middle of the list, can be less efficient due to the need to shift elements.
import { ArrayList } from "collection-kit";
import { ArrayList } from "collection-kit";
const list = new ArrayList();
list.add(10);
list.add(20);
list.add(30);
console.log("Size:", list.size()); // 3
console.log("First element:", list.get(0)); // 10
// Iterate through elements
for (let i = 0; i < list.size(); i++) {
console.log(`Element ${i}:`, list.get(i));
}