Подскажите, пожалуйста, в чем же может быть тут ошибка....
package com.javarush.task.task08.task0817;
import java.util.*;
/*
Нам повторы не нужны
*/
public class Solution {
public static HashMap<String, String> createMap() {
HashMap<String, String> map = new HashMap<>();
for(int i = 0; i < 10; i++)
map.put("key" + i, "value" + i);
return map;
}
public static void removeTheFirstNameDuplicates(Map<String, String> map) {
Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry<String, String> pair = iterator.next();
int count = 0;
for(Map.Entry<String, String> entry : map.entrySet()) {
if(entry.getValue().equals(pair.getValue())) {
count++;
}
}
if(count > 1) {
removeItemFromMapByValue(map, pair.getValue());
}
}
}
public static void removeItemFromMapByValue(Map<String, String> map, String value) {
HashMap<String, String> copy = new HashMap<String, String>(map);
for (Map.Entry<String, String> pair : copy.entrySet()) {
if (pair.getValue().equals(value))
map.remove(pair.getKey());
}
}
public static void main(String[] args) {
}
}