Maps in Java
A Map represents an object that maps unique keys to values. A Map cannot contain duplicate keys; each key can map to at most one value. Unlike the other collection interfaces (List, Set, Queue), Map does not inherit from Collection or Iterable.
Implementing Classes Map
1. HashMap (Unordered, Default Choice)
- HashMap Introduction & Why HashMap
- Creating HashMap & Adding Elements
- Accessing, Updating & Removing Elements
- Iteration & Common Methods
- HashMap Internal Workings & Time Complexity
- HashMap vs. HashTable & Comparisons / Q&As
- HashMap Interview Questions
2. LinkedHashMap (Preserves Insertion/Access Order)
- LinkedHashMap Introduction & Why LinkedHashMap
- Creating LinkedHashMap & Adding / Accessing Elements
- Updating & Removing Elements
- Iteration & Internal Working
- Comparison with HashMap & Interview Questions
3. TreeMap (Sorted Key Ordering)
- TreeMap Introduction & Why TreeMap
- Creating TreeMap & Adding / Accessing Elements
- Updating & Removing Elements
- Iteration & NavigableMap Methods
- Internal Working & Red-Black Tree balancing
- Comparison with HashMap & Interview Questions
4. Hashtable (Thread-safe monitor lock, Obsolete)
- Hashtable Introduction & Why HashTable
- Creating HashTable & Common Methods
- Internal Working & HashTable vs. HashMap
- Interview Questions
Map Implementations Summary
graph TD
Map["Map Interface"]
HashMap["HashMap (Hashing, Unordered)"]
LinkedHashMap["LinkedHashMap (Doubly Linked, Insertion/Access Order)"]
SortedMap["SortedMap Interface"]
TreeMap["TreeMap (Red-Black Tree, Sorted Keys)"]
Hashtable["Hashtable (Synchronized, Legacy)"]
Map --> HashMap
HashMap --> LinkedHashMap
Map --> SortedMap
SortedMap --> TreeMap
Map --> Hashtable Back to Module Home: Collection Framework Index