Please show
package com.codegym.task.task08.task0818;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/*
Only for the rich
*/
public class Solution {
public static HashMap<String, Integer> createMap() {
HashMap<String, Integer> list = new HashMap<>();
list.put("Alex",4500);
list.put("Satewa",7900);
list.put("Mach", 2000);
list.put("Ouem", 500);
list.put("Guansou", 270);
list.put("Picaho", 100);
list.put("Ramakant", 10000);
list.put("Joy", 499);
list.put("Cindy", 2000);
list.put("Sean", 376);
return list;
}
public static void removeItemFromMap(HashMap<String, Integer> map) {
HashMap<String, Integer> copy = new HashMap<>(map); // a copy variable of map argument
Iterator<Map.Entry<String, Integer>> itr = copy.entrySet().iterator(); // an iterator of the copy
while (itr.hasNext())
{
if (itr.next().getValue() < 500)
{
map.remove(itr.next().getKey());
}
}
}
public static void main(String[] args) {
/** HashMap<String, Integer> New = createMap();
removeItemFromMap(New);
for (Map.Entry<String, Integer> show : New.entrySet()
) {
System.out.println(show);
} **/
}
}