You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Arrays are powerful but fixed in size. Java's Collections Framework provides dynamic, resizable data structures — lists, sets, maps, and queues. Generics add type safety so collections only hold the types you specify.
Iterable
└── Collection
├── List (ordered, allows duplicates)
├── Set (no duplicates)
└── Queue (FIFO ordering)
Map (key-value pairs — separate hierarchy)
A List is an ordered collection that allows duplicates.
import java.util.ArrayList;
import java.util.List;
List<String> names = new ArrayList<>();
names.add("Alice");
names.add("Bob");
names.add("Alice"); // duplicates allowed
System.out.println(names); // [Alice, Bob, Alice]
System.out.println(names.get(0)); // Alice
System.out.println(names.size()); // 3
names.remove("Alice"); // removes first occurrence
System.out.println(names); // [Bob, Alice]
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.