Не пропускает одно условие, не понимаю почему
package com.javarush.task.task08.task0817;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/*
Нам повторы не нужны
*/
public class Solution {
public static Map<String, String> createMap() {
Map<String, String> m = new HashMap<String, String>();
m.put("a", "a");
m.put("b", "b");
m.put("c", "a");
m.put("d", "c");
m.put("e", "a");
m.put("f", "d");
m.put("g", "e");
m.put("h", "a");
m.put("i", "f");
m.put("j", "g");
return m;
}
public static void removeTheFirstNameDuplicates(Map<String, String> map) {
Map<String, String> copy = new HashMap<>(map);
Iterator<Map.Entry<String, String>> i = map.entrySet().iterator();
Iterator<Map.Entry<String, String>> i2 = copy.entrySet().iterator();
while (i.hasNext()){
Map.Entry <String, String> p = i.next();
String s = p.getValue();
removeItemFromMapByValue(map, s);
}
}
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) {
}
}