Lesson 16: Collections: List, ArrayList & LinkedList
17 Jul 2026 1 min Swarnil Singhai
Lists hold ordered, resizable sequences — ArrayList is fast for random access, LinkedList is fast for frequent inserts/removals at the ends.
Real-time example
A shopping cart uses an ArrayList<CartItem> because customers mostly scroll and view items by index, not insert in the middle.
List<String> cart = new ArrayList<>();
cart.add("Wireless Mouse");
cart.add("Mechanical Keyboard");
cart.remove("Wireless Mouse");
System.out.println(cart); // [Mechanical Keyboard]
What's happening
ArrayList is backed by a resizable array, so get(i) is O(1) but inserting in the middle shifts elements — O(n).
Default to ArrayList unless you've measured a real need for LinkedList's O(1) insert at the head/tail.
Advertisement