Что не так ? Помогите!!!
package com.javarush.task.task08.task0817;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/*
Нам повторы не нужны
*/
public class Solution {
public static Map<String, String> createMap() {
//напишите тут ваш код
Map<String, String> map = new HashMap<>();
map.put("Первый","Василий");
map.put("Второй","Василий");
map.put("Третий","Василий");
map.put("Четвертый","Василий");
map.put("Пятый","Василий");
map.put("Шестой","Василий");
map.put("Седьмой","Василий");
map.put("Восьмой","Василий");
map.put("Девятый","Василий");
map.put("Десятый","Василий");
return map;
}
public static void removeTheFirstNameDuplicates(Map<String, String> map)
{
Iterator<Map.Entry<String, String>> iterator1 = map.entrySet().iterator();
int n=0;
while (iterator1.hasNext())
{
Map.Entry<String, String> pair1 = iterator1.next();
String key1 = pair1.getKey();
String value1 = pair1.getValue();
Iterator<Map.Entry<String, String>> iterator2 = map.entrySet().iterator();
while (iterator2.hasNext())
{
Map.Entry<String ,String> pair2 = iterator2.next();
String key2 = pair2.getKey();
String value2 = pair2.getValue();
if (value1.equals(value2)){ n++;}
}
if (n>1) {iterator1.remove();}
}
removeItemFromMapByValue(map,"value");
}
public static void removeItemFromMapByValue(Map<String, String> map, String value) {
Map<String, String> copy = new HashMap<>(map);
for (Map.Entry<String, String> pair : copy.entrySet()) {
if (pair.getValue().equals(value)) {
map.remove(pair.getKey());
}
}
}
public static void main(String[] args) {
}
}