October 2017
Beginner
318 pages
7h 26m
English
Once we've set up the Map, with all our information already in our program, all we need to do is ask it some questions and make sure we get the right responses:
System.out.println(famousPeople.get("Addams"));
We use the get() function to ask our Map the basic question that it's designed to answer, "What is the value paired with a given key?" So, let's ask our Map, "What is the value paired with Addams?", or in more understandable English terms, "What is the first name of the person in our Map whose last name is Addams?" When we run this program, we get the expected result, that is, Jane:

Let's just run it ...
Read now
Unlock full access