A unified architecture for storing, managing, and manipulating groups of objects.
Includes interfaces, implementations (classes), and utility methods.
Core Interfaces
Interface | Description |
---|---|
Collection | Root interface (for lists, sets, queues) |
List | Ordered collection with duplicates allowed |
Set | Unordered, no duplicates |
Queue | FIFO structure (some support LIFO) |
Map | Key-value pairs (not part of Collection) |
Map is a part of the framework, but not a subtype of Collection
Collection Hierarchy (Simplified)
Iterable
β
Collection
/ | \
List Set Queue
Map (separate branch)
Key Features
- Built-in data structures.
- Ready-to-use implementations.
- Generic support (e.g. List
). - Algorithms in Collections class.
- Consistent API (add, remove, size, containsβ¦).
Example
List<String> list = new ArrayList<>();
list.add("Hello");
Set<Integer> set = new HashSet<>();
set.add(10);
Map<String, Integer> map = new HashMap<>();
map.put("A", 1);
Common Implementations
Type | Classes |
---|---|
List | ArrayList, LinkedList, Vector |
Set | HashSet, LinkedHashSet, TreeSet |
Queue | PriorityQueue, ArrayQueue |
Map | HashMap, LinkedHashMap, TreeMap, Hashtable |
Tip
Be ready to explain:
- why use List vs Set vs Map,
- the core difference between Collection and Collections,
- why Map is not a subtype of Collection.
Parent: _Collections