37 Working with Map

 

After reading this lesson, you will be able to

  • Retrieve the value associated with a key
  • Get all keys and all values stored in a Map
  • Check its size and the feature of its entries
  • Filter its elements based on given criteria

In the previous lesson, you learned about the basics of Map. In this lesson, you’ll master the most common operations you can apply to it. You’ll use different strategies to retrieve a value linked to a given key. You’ll get the keys and the values in an instance of a Map. Finally, you will get its size, inquire about its entries’ properties, and filter its elements according to their characteristics by reusing the same methods you saw for List and Set. In the capstone, you will apply these operations to extract the book information from a CSV file and create your library’s book collection.

37.1 Retrieving a value for a given key

Consider the program to track the exam registration that you are implementing. Imagine you now need to retrieve the students who have enrolled for a given exam session.

37.2 Getting all keys and values

 
 
 

37.3 Other operations on Map

 
 
 

Summary

 
 
 

Answers to quick checks

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest