i couldn't figure out.
where i go wrong.
someone plis help me out.
thank you
package com.codegym.task.task08.task0817;
import java.util.HashMap;
import java.util.Map;
public class Solution{
public static HashMap<String, String> createMap(){
HashMap<String, String> map = new HashMap<String, String>();
map.put("haokip1", "stephen0");
map.put("haokip2", "stephen9");
map.put("haokip3", "stephen8");
map.put("haokip4", "stephen7");
map.put("haokip5", "stephen6");
map.put("haokip6", "stephen5");
map.put("haokip7", "stephen4");
map.put("haokip8", "stephen3");
map.put("haokip9", "stephen4");
map.put("haokip0", "stephen2");
return map;
}
public static void removeFirstNameDuplicates(Map<String, String> map){
int count = 0;
HashMap<String, String> copy = new HashMap<String, String>(map);
for(Map.Entry<String, String>pair1 : map.entrySet()){
String first = pair1.getValue();
for(Map.Entry<String, String>pair2 : copy.entrySet()){
String second = pair2.getValue();
if(second.equals(first)){
count++;
}
if(count>=2){
//map.remove(pair1.getValue());
removeItemFromMapByValue(map, first);
}
count = 0;
}
}
}
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){
}
}