I don't know if there's something wrong with it,if it has,plz help me thx.need specific details very appreciate
package com.codegym.task.task08.task0817;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
/*
We don't need repeats
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String,String> hashmap = new HashMap<String,String>();
hashmap.put("leo" , "leo");
hashmap.put("wo" , "woshi");
hashmap.put("wori" , "wori");
hashmap.put("woshishui" , "wobushi");
hashmap.put("wohendiao" , "wohendiao");
hashmap.put("wob" , "woc");
hashmap.put("nihao" , "nibuhao");
hashmap.put("woshita" , "woshita");
hashmap.put("shui" , "woniu");
hashmap.put("hao" , "hao");
return hashmap;
}
public static void removeFirstNameDuplicates(Map<String, String> map) {
//write your code here
int count = 1;
Map<String, String> helper = new HashMap<String,String>();
Iterator<Map.Entry<String,String>> iterator = map.entrySet().iterator();
while(iterator.hasNext()){
Map.Entry<String,String> pair = iterator.next();
String key = pair.getKey();
String value = String.valueOf(count);
helper.put(key,value);
if(map.containsKey("key")){
count++;
}
}
Iterator<Map.Entry<String,String>> iterator1 = helper.entrySet().iterator();
while(iterator.hasNext()){
Map.Entry<String,String> pair = iterator1.next();
String key = pair.getKey();
String value = pair.getValue();
if(Integer.parseInt(value) >1){
removeItemFromMapByValue(helper,value);
}
}
}
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) {
}
}