public class Solution { public static Map<String, Date> createMap() throws ParseException { DateFormat dateFormat = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH); Map<String, Date> map = new HashMap<>(); map.put("Сталлоне", dateFormat.parse("May 1 2012")); map.put("Silva", dateFormat.parse ("June 2 2010")); map.put("Igor", dateFormat.parse("April 3 1994")); map.put("Vasa", dateFormat.parse("January 24 2000")); map.put("Elza", dateFormat.parse("February 22 2001")); map.put("Vanya", dateFormat.parse("July 10 2005")); map.put("Olga", dateFormat.parse("August 15 2005")); map.put("Iga", dateFormat.parse("September 5 2007")); map.put("Goga", dateFormat.parse("December 30 2000")); map.put("Vigi", dateFormat.parse("May 1 2009")); return map; } public static void removeAllSummerPeople(Map<String, Date> map) { // Iterator<Map.Entry<String,Date>> iterator = map.entrySet().iterator(); // while (iterator.hasNext()){ // Map.Entry<String, Date> pair = iterator.next(); // if (iterator.equals("June")){ // iterator.remove(); // } // } Iterator<Map.Entry<String,Date>> iterator = map.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry<String, Date> pair = iterator.next(); Date date = pair.getValue(); if(date.getMonth() == 5 || date.getMonth() == 6 || date.getMonth() == 7) { iterator.remove(); } } // map.entrySet().removeIf(entry -> entry.getValue().equals("June") ); } public static void main(String[] args) throws ParseException { // removeAllSummerPeople(createMap()); // // for (Map.Entry<String, Date> pair : createMap().entrySet()) { // System.out.println(pair.getKey() + " " + pair.getValue()); // // } } }