October 2017
Beginner
318 pages
7h 26m
English
To begin, I've gone ahead and imported java.util where the Map interface lives. Next, I'll get rid of the last two println statements that prints the firstNames and lastNames arrays. Instead, at this point in our code, when our firstNames and lastNames arrays have been set up, let's start constructing our Map. For this, add the following line of code:
Map<String, String> famousPeople = new HashMap<>();
We begin by using the Map keyword and then, as with most data structures, we tell Java what type of information our Map is going to take. Maps take two sets of information, so we'll have to give it two information types that are comma-separated. The first information type is the information type for the Map's keys, and the second ...
Read now
Unlock full access