Why don't the middle two methods require a copy of the HashMap such as:
HashMap<String, String> copy = new HashMap<String, String>(map);
like similar tasks on this lesson do?
package com.codegym.task.task08.task0815;
import java.util.HashMap;
import java.util.HashSet;
/*
Census
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String, String> map = new HashMap<String, String>();
map.put("first", "Rain");
map.put("first", "Roger");
map.put("first", "Clarence");
map.put("first", "Ernest");
map.put("first", "David");
map.put("first", "Tom");
map.put("first", "Jeff");
map.put("first", "Eva");
map.put("first", "Mary");
map.put("first", "Claudia");
return map;
}
public static int getSameFirstNameCount(HashMap<String, String> map, String name) {
//write your code here
int count = 0;
for (String nameTmp : map.values()) {
if (nameTmp.equals(name)) count++;
}
return count;
}
public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
//write your code here
int count = 0;
for (String lastNameTmp : map.keySet()) {
if (lastNameTmp.equals(lastName)) count++;
}
return count;
}
public static void main(String[] args) {
}
}