Skip to content
Veltoryx Technologies
ProLesson 7.2Intermediate3 min readUpdated 30 October 2026

List: ArrayList vs LinkedList

Use List day to day, see how ArrayList and LinkedList work inside, compare their speed, and avoid the remove-while-looping trap.

A List keeps elements in order, allows duplicates, and lets you access them by index. You'll use ArrayList in the vast majority of cases. But "ArrayList vs LinkedList" is a classic interview question, so let's see what's inside each.

01Everyday List operations

ListBasics.java
import java.util.ArrayList;
import java.util.List;

public class ListBasics {
    public static void main(String[] args) {
        List<String> tasks = new ArrayList<>();
        tasks.add("write code");
        tasks.add("test");
        tasks.add(0, "plan");                 // insert at index 0
        tasks.add("test");                    // duplicates allowed

        System.out.println(tasks);
        System.out.println(tasks.get(1));
        System.out.println(tasks.indexOf("test"));
        System.out.println(tasks.contains("deploy"));
        tasks.set(3, "deploy");               // replace
        tasks.remove("plan");                 // remove by value
        System.out.println(tasks + " size=" + tasks.size());
    }
}
Expected output
[plan, write code, test, test]
write code
2
false
[write code, test, deploy] size=3

Loading the rest of the lesson…