Guided Notes

Collections

List, ArrayList, and LinkedList; Set and HashSet; Map and HashMap; sorting; iterators; and wrapper classes.

The Collections Framework

Slide 1 / 5

java.util provides ready-made data structures that grow and shrink automatically:

β€’ List β€” an ordered sequence that allows duplicates (ArrayList, LinkedList). β€’ Set β€” unique values only (HashSet, TreeSet, LinkedHashSet). β€’ Map β€” key–value pairs with unique keys (HashMap, TreeMap, LinkedHashMap).

Declare variables by the interface and create by the class: List<String> names = new ArrayList<>();

The <String> is a generic type: the list only holds Strings.

← Files & I/O