Line 41 : method remove in interface java.util.Iterator<E> cannot be applied to given types; required: no arguments found: java.lang.String reason: actual and formal argument lists differ in length.
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() {
//write your code here
HashMap<String, Integer> map = new HashMap<String, Integer>(){{
put("dafdfa",100);
put("gdafd",200);
put("hdsafe",300);
put("gdakg",400);
put("hdafd",500);
put("hdafe",600);
put("gdafe",700);
put("hafe",800);
put("hrsf",900);
put("kjfgs",1000);
}};
return map;
}
public static void removeItemFromMap(HashMap<String, Integer> map) {
//write your code here
Iterator<Map.Entry<String, Integer>> iterator = map.entrySet().iterator();
while (iterator.hasNext())
{
//get a pair of elements
Map.Entry<String, Integer> pair = iterator.next();
String key = pair.getKey(); //key
int value = pair.getValue(); //value
if(value<500){
iterator.remove(key);
}
}
}
public static void main(String[] args) {
}
}