Ребят, я не понимаю чем не подходит метод createMap(). Объясните пожалуйста.
package com.javarush.task.task08.task0815;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Collection;
import java.util.Iterator;
/*
Перепись населения
*/
public class Solution {
public static Map<String, String> createMap() {
//напишите тут ваш код
Map<String, String> persons = new HashMap<>();
persons.put("Johnson", "Kek");
persons.put("Cheburekov", "Lol");
persons.put("Lolev", "Kek");
persons.put("Lolev", "Lul");
persons.put("Lulov", "Zabor");
persons.put("Zaborov", "Vol");
persons.put("Ololoev", "Ololosha");
persons.put("Chelovekov", "Pauk");
persons.put("Durov", "Pavel");
persons.put("Pavlov", "Dur");
return persons;
}
public static int getCountTheSameFirstName(Map<String, String> map, String name) {
//напишите тут ваш код
int count = 0;
// String targetName;
Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();
while(iter.hasNext()) {
Map.Entry<String, String> pair = iter.next();
String currentName = pair.getValue();
System.out.println(currentName);
if (currentName.equals(name)) {
count++;
}
}
return count;
}
public static int getCountTheSameLastName(Map<String, String> map, String lastName) {
//напишите тут ваш код
int count = 0;
Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();
while(iter.hasNext()) {
Map.Entry<String, String> pair = iter.next();
String currentLastName = pair.getKey();
if (currentLastName.equals(lastName)) {
count++;
}
}
return count;
}
public static void main(String[] args) {
}
}