The mentor is saying "Check the createMap() method. The HashMap should consist of 10 entries that represent (last name, first name) pairs."
However in looking at the createMap() method I have ten entries and they are not duplicate items, so I'm not seeing what is the issue is with how I declared and added items to the HashMap.
Please advise.
package com.codegym.task.task08.task0815;
import java.util.HashMap;
import java.util.HashSet;
/*
Census
*/
public class Solution {
public static HashMap<String, String> createMap() {
HashMap<String,String> names = new HashMap<String, String>();
names.put("Taylor","Andrea");
names.put("Markley","Phil");
names.put("Taylor","Rosanna");
names.put("Williams","Andrea");
names.put("Williams","Laverne");
names.put("Taylor","Andrea");
names.put("Taylor","Dan");
names.put("Golovko","Steve");
names.put("Cuff","Michele");
names.put("Brady","Keith");
return names;
}
public static int getSameFirstNameCount(HashMap<String, String> map, String name) {
int firstNameCount = 0;
for (HashMap.Entry<String, String> namePair : map.entrySet()) {
if (namePair.getValue().equalsIgnoreCase(name))
firstNameCount++;
}
return firstNameCount;
}
public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
int lastNameCount = 0;
for (HashMap.Entry<String, String> namePair : map.entrySet()) {
if (namePair.getKey().equalsIgnoreCase(lastName))
lastNameCount++;
}
return lastNameCount;
}
public static void main(String[] args) {
}
}