Please help me with my code.It is not satisfying 4th condition.What's the error?
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() {
HashMap <String,String> a= new HashMap<String,String>();
a.put("1","A");
a.put("2","B");
a.put("3","B");
a.put("4","c") ;
a.put("5","B");
a.put("6","B");
a.put("7","B") ;
a.put("8","B") ;
a.put("9","B") ;
a.put("10","e");//write your code here
// removeFirstNameDuplicates(a);
return a;
}
public static void removeFirstNameDuplicates(Map<String, String> map) {
//String s=map.values();
//Iterator<Map.Entry<String,String>> b= a.entrySet.iterator();
HashMap <String,String> aa= new HashMap<String,String>(map);
Iterator<Map.Entry<String,String>> p=aa.entrySet().iterator();
while(p.hasNext()){
Map.Entry<String,String> c=p.next();
String z= c.getValue();
removeItemFromMapByValue(map,z); //write your code here
}
}
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) {
}
}