Вот всё же работает, но не проходит. Почему, не понимаю, подскажите)
package com.javarush.task.task08.task0815;
import java.util.*;
/*
Перепись населения
*/
public class Solution {
public static Map<String, String> createMap() {
Map<String,String> map = new HashMap<>();
map.put("фамилия", "имя");
map.put("petuh1", "petuhevich11");
map.put("petuh2", "petuhevich1");
map.put("petuh3", "petuhevich");
map.put("petuh4", "petuhevich22");
map.put("petuh6", "petuhevich");
map.put("petuh7", "petuhevich");
map.put("petuh5", "petuhevich22");
map.put("petuh8", "petuhevich");
map.put("petuh9", "petuhevich");
return map;
}
public static int getCountTheSameFirstName(Map<String, String> map, String name) {
int count1 = 0;
Set<String> set = new HashSet<>();
for (String a :map.values()){
set.add(a);
}
for (String b: set){
if (b==name)
count1++;
}
return count1;
}
public static int getCountTheSameLastName(Map<String, String> map, String lastName) {
int count1 = 0;
Set<String> set1 = new HashSet<>();
for (String a :map.keySet()){
set1.add(a);
}
for (String b: set1){
if (b==lastName)
count1++;
}
return count1;
}
public static void main(String[] args) {
getCountTheSameFirstName(createMap(),"имя");
getCountTheSameLastName(createMap(),"фамилия");
}
}