я так понимаю, что-то я делаю не верно, но в чем именно проблема понять не могу.
public static int getCountTheSameFirstName(Map<String, String> map, String name)
разве тут мы не объявляем переменную name ?package com.javarush.task.task08.task0815;
import java.util.HashMap;
import java.util.Map;
/*
Перепись населения
*/
public class Solution {
public static Map<String, String> createMap() {
Map<String, String> map = new HashMap<String, String>();
map.put("first", "Mama");
map.put("second", "Mila");
map.put("third", "Ramu");
map.put("third1", "Ramu1");
map.put("third2", "Ramu2");
map.put("third3", "Ramu3");
map.put("third4", "Ramu4");
map.put("third5", "Ramu5");
map.put("third6", "Ramu6");
map.put("third7", "Ramu7");
return map;
}
public static int getCountTheSameFirstName(Map<String, String> map, String name) {
int a = 0;
for (HashMap.Entry<String, String> pair : map.entrySet()) {
if(name.equals(pair.getValue())){
a++;
}
}
return a;
}
public static int getCountTheSameLastName(Map<String, String> map, String lastName) {
int a = 0;
for (HashMap.Entry<String, String> pair : map.entrySet()) {
if(name.equals(pair.getKey())){
a++;
}
}
return a;
}
public static void main(String[] args) {
}
}