4 условие
package com.javarush.task.task08.task0817;
import java.util.HashMap;
import java.util.Map;
/*
Нам повторы не нужны
*/
public class Solution {
public static Map<String, String> createMap() {
//напишите тут ваш код
HashMap<String, String> map = new HashMap<>();
map.put("But","Gift");
map.put("Both","Hey");
map.put("Been","Hey");
map.put("GBP hi","Baths");
map.put("Info","Church");
map.put("JCI","HDTV");
map.put("Do","Bath");
map.put("Favour","Baths");
map.put("JCC","Just");
map.put("For","Hi");
return map;
}
public static void removeTheFirstNameDuplicates(Map<String, String> map) {
//напишите тут ваш код
Map<String, String> copy = new HashMap<>(map);
for (Map.Entry<String, String> pair : copy.entrySet()) {
String ma = pair.getValue();
for(Map.Entry<String, String> ifmap : copy.entrySet())
if (ifmap.getValue() == ma)
removeItemFromMapByValue(map, ma);
}
}
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) {
}
}