Вроде, всё правильно написано, никаких ошибок нет, но почему то ничего не удаляет.
package com.javarush.task.task08.task0818;
import java.util.*;
/*
Только для богачей
*/
public class Solution {
public static Map<String, Integer> createMap() {
Map<String, Integer> map = new HashMap<>();
map.put("Иванов", 400);
map.put("Петров", 1400);
map.put("Сидоров", 450);
map.put("Алексеев", 2400);
map.put("Сергеев", 2500);
map.put("Николаев", 4500);
map.put("Гуляев", 200);
map.put("Стояев", 300);
map.put("Сидяев", 4600);
map.put("Лежаев", 1000);
return map;
}
public static void removeItemFromMap(Map<String, Integer> map) {
Map<String, Integer> salary = new HashMap<>(map);
Iterator<Map.Entry<String, Integer>> iterator = salary.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<String, Integer> pair = iterator.next();
int value = pair.getValue();
if (value < 500){
iterator.remove();
}
}
}
public static void main(String[] args) {
}
}