it says that package map2 not found even though I'm pointing to map2 Map when i try to create iterator
package com.codegym.task.task08.task0817;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
import java.util.Collections;
/*
We don't need repeats
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String, String> map = new HashMap<String, String>();
map.put("Jorie","Peralta");
map.put("Hailey","Williams");
map.put("Jorie","Cruz");
map.put("Honey","Smith");
map.put("Lexi","Role");
map.put("Josh","Ching");
map.put("Max","Mendoza");
map.put("Josh","Sta ana");
map.put("Michael","Garcia");
map.put("Jorie","Mitchel");
return map;
}
public static void removeFirstNameDuplicates(Map<String, String> map) {
//write your code here
HashMap<String, String> map2 = new HashMap<String, String>();
for(Map.Entry<String, String> pair : map.entrySet()){
String name = pair.getKey();
String lname = pair.getValue();
map2.put(lname, name);
}
Iterator<String> it = new map2.iterator();
while(it.hasNext()){
removeItemFromMapByValue(map2,it.next().getValue());
}
}
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) {
}
}