any specific method t compare values of map
please help
package com.codegym.task.task08.task0817;
import java.util.*;
/*
We don't need repeats
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String,String> map = new HashMap<>();
map.put("1", "farhan");
map.put("2", "sahar");
map.put("3", "farah");
map.put("4", "sahar");
map.put("5", "saba");
map.put("6", "kiran");
map.put("7", "tayyab");
map.put("8", "sarwar");
map.put("9", "masood");
map.put("10", "parha");
return map;
}
public static void removeFirstNameDuplicates(Map<String, String> map) {
//write your code here
int count = 0;
for (Map.Entry<String, String> t : map.entrySet()) {
String s0 = t.getValue();
for (Map.Entry<String, String> s : map.entrySet())
{
String s1 = s.getValue();
if (s0.equals(s1))
{
removeItemFromMapByValue(map,s1);
count = 1;
}
if(count ==1)
{
removeItemFromMapByValue(map,s0);
}
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) throws Exception {
HashMap<String,String> map = new HashMap<>();
map = createMap();
System.out.print(map);
}
}