It returns good values but here it doenst meet the requirements. Do you have idea why?
package pl.codegym.task.task08.task0818;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/*
Tylko dla bogaczy
*/
public class Solution {
public static HashMap<String, Integer> utworzMap() {
//tutaj wpisz swój kod
HashMap<String, Integer> map = new HashMap<>();
map.put("Rybsfki", 1231);
map.put("Rdfgdf", 123);
map.put("Rfff", 500);
map.put("Rybqski", 5000);
map.put("Rewe", 131);
map.put("Zqw", 765);
map.put("Rybski", 4567);
map.put("Zoiuy",9876);
map.put("Zjhgf", 234);
map.put("Znhgf", 8765);
return map;
}
public static HashMap<String, Integer> usunPozycjeZmap(HashMap<String, Integer> map) {
//tutaj wpisz swój kod
HashMap<String, Integer> map2 = new HashMap<>(map);
Iterator<Map.Entry<String, Integer>> iterator = map2.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Integer> entry = iterator.next();
int value = entry.getValue();
if (value < 500) {
iterator.remove(); // always use remove() method of iterator
}
}
return map2;
}
public static void main(String[] args) {
}
}