PLEASE SUBSCRIBE!!!
In the previous lesson ( • Java Programming: Lesson 54 - Sets ), we took a look at sets, which are a data structure in Java in which no duplicate elements are allowed. In this lesson, we take a look at dictionaries, which are key-value pairs between objects. Keys must be unique, but multiple keys can map to the same value.
Dictionaries are a set of key-value pairs. The keys in a dictionary must be unique, but the values need not be unique. The class for dictionaries in Java is called a HashMap. The keys and values in a map must both be objects, but they do not have to be the same data type (but all the keys must be the same data type as each other, and same for the values).
1. import java.util.HashMap;
2. create an instance of HashMap;
3. google HashMap Java API
4. operate on your dictionary using the put, replace, isEmpty, and other methods dicussed in this video or on the API
0:34 Review of Collections.sort(list), max(list), min(list), Iterators, Stacks, and Queues
4:22 Review of Sets
8:00 NEW: Intro to Dictionaries
12:09 NEW: Creating a Map
More information on HashMaps if you skip ahead: • Java Programming: Lesson 57 - More Me... (J57)
A somewhat similar lesson regarding dictionaries in Python is available here: • Python Programming: Lesson 22 - List ... (even more details, • Python Programming: Lesson 56 - Advan... ) (P56)
Further down the road, we will see hashtables, which are extremely similar to hashmaps: • Java Programming: Lesson 64 - Hashtables (J64)
A third dictionary: linked hash maps • Java Programming: Lesson 68 - Linked ...
A fourth dictionary: concurrent hash maps • Java Programming: Lesson 69 - Concurr...
Ready for the next lesson, which reviews arrays, ArrayLists, LinkedLists, stacks, queues, and sets in great detail? Check it out here: • Java Programming: Lesson 56 - Advance... (J56)
Thanks for watching, and PLEASE SUBSCRIBE!!!