1. i know that you can't remove stuff from the map you are iterating 2. i tried stuff from people that posted with the alterations they said it worked for them. Not for me tho 3. so i even tried instead of coping and .remove from the map, to create a new map and .put all the objects that are not supposed to be deleted ( should be the same, right?). than coping it to the map: map = m2. But this is not altering the map variable in main. 4. the previous thing works if i change the removeAll... from a VOID to a HASHMAP with a return value, so when i call it in the main: map = removeAllSummerPeople(map); it works totally fine and the map is altered. But of course the conditions do not allow this. --> So, why is it not working in the first place, that i read the copy of the map and remove from the original? -->And why does the [3.] not alter the map variable in main? Is the varible in main suppose to be 'final' or 'public' or smt?? I ran into the problem before (void not changing the main variable) but i don´t know how I managed last time... I do NOT only want to know what works, but also WHY this does not. thanks for the answers Here is the code that works for me but is not valid:
</package com.codegym.task.task08.task0816;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;


public class Solution {
    public static HashMap<String, Date> createMap() throws ParseException {
        DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
        HashMap<String, Date> map = new HashMap<String, Date>();

        map.put("Stallone", df.parse("JUNE 1 1980"));
        map.put("a", df.parse("JUNE 1 1980"));
        map.put("b",df.parse("JUNE 1 1980"));
        map.put("c",df.parse("SEPTEMBER 1 1980"));
        map.put("d",df.parse("JUNE 1 1980"));
        map.put("e",df.parse("MARCH 1 1980"));
        map.put("f",df.parse("JUNE 1 1980"));
        map.put("g",df.parse("JUNE 1 1980"));
        map.put("h",df.parse("JUNE 1 1980"));
        map.put("i",df.parse("DECEMBER 1 1980"));

        return map;
    }



        public static HashMap<String, Date> removeAllSummerPeople(HashMap<String, Date> map) {
            //write your code here

            HashMap<String, Date> m2 = new HashMap<>();


            for(Map.Entry<String, Date> entry : map.entrySet())
            {
                int d = entry.getValue().getMonth();

                String s = entry.getKey();

                Date da = entry.getValue();

                if(d <5 || d > 7)
                    //System.out.println("d");
                    m2.put(s, da);

            }

            return m2;



    }

    public static void main(String[] args) throws ParseException {
       HashMap<String, Date> map = createMap();

        for(Map.Entry<String, Date> entry : map.entrySet())
            System.out.println(entry.getKey() +" : "+ (entry.getValue().getMonth()+1));


         map = removeAllSummerPeople(map);


        for(Map.Entry<String, Date> entry : map.entrySet())
            System.out.println(entry.getKey() +" : "+ (entry.getValue().getMonth()+1));



    }
}
>