i заходилn't very more time, because im noob, sorry(.
Where is problem?
Ну так что?
package com.javarush.task.task08.task0815;
import java.util.*;
/*
Перепись населения
*/
public class Solution {
public static Map<String, String> createMap() {
Map<String, String> hm =new HashMap<>();
hm.put("Васильков","Дмитрий");
hm.put("Фамильяр","Никитос");
hm.put("Караул","Аркадий");
hm.put("Лолкексон","Сон-ДжинВу");
hm.put("Васильков","Синий");
hm.put("Ахриненов","Кот");
hm.put("Одинаковов","Цезарь");
hm.put("Стеклова","Готоге");
hm.put("Паровозов","Аркадий");
hm.put("Йохохов","Ахрин");
return hm;
//напишите тут ваш код
}
public static int getCountTheSameFirstName(Map<String, String> map, String name) {
//напишите тут ваш код
int t=0;
Iterator<Map.Entry<String,String>> iter = map.entrySet().iterator();
while (iter.hasNext()){
Map.Entry<String,String> ent = iter.next();
String s = ent.getKey();
if(s==name) t++;
}
return t;
}
public static int getCountTheSameLastName(Map<String, String> map, String lastName) {
//напишите тут ваш код
int t=0;
Iterator<Map.Entry<String,String>> iter = map.entrySet().iterator();
while (iter.hasNext()){
Map.Entry<String,String> ent = iter.next();
String s = ent.getValue();
if(s==lastName) t++;
}
return t;
}
public static void main(String[] args) {
}
}