public static void removeItemFromMap(HashMap<String, Integer> map) {
HashMap<String,Integer> m= new HashMap<>(map); //write your code here
Iterator<HashMap.Entry<String,Integer>>I= m.entrySet().iterator();
while(I.hasNext())
{
int value=I.next().getValue();
if(value<500)
I.remove();
}
}
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> map= new HashMap<>(); //write your code here
map.put("Toscano",800);
map.put("Flores",900);
map.put("Lopez", 700);
map.put("Maldonado", 800);
map.put("Ceiz",400);
map.put("Alonso",300);
map.put("Dolores",700);
map.put("Gonzaoles",600);
map.put("Hidalgo",700);
map.put("Francisca",800);
return map;
}
public static void removeItemFromMap(HashMap<String, Integer> map) {
HashMap<String,Integer> m= new HashMap<>(map); //write your code here
Iterator<HashMap.Entry<String,Integer>>I= m.entrySet().iterator();
while(I.hasNext())
{
int value=I.next().getValue();
if(value<500)
I.remove();
}
}
public static void main(String[] args) {
}
}