Hello guys!
I was able to solve this task by using just an old fashioned 'if' and 'while' loop but I was thinking about approaching this issue differently but couldn't make it work.
Could you please help me figure out what I should change in my code here to make it work and solve this task 0816 using Streams API? Thanks in advance :)
public static void removeAllSummerPeople(HashMap<String, Date> map) {
Iterator<Map.Entry<String, Date>> iter = map.entrySet().iterator();
Calendar cal = new GregorianCalendar();
while (iter.hasNext()) {
Map.Entry<String, Date> entry = iter.next();
cal.setTime(entry.getValue());
map.entrySet().removeIf(v -> v.getValue().getTime() == Calendar.JUNE
|| v.getValue().getTime() == Calendar.JULY
|| v.getValue().getTime() == Calendar.AUGUST);
}
}
I tried also another approach similar to my 'original' solution but without any luck:
map.entrySet().removeIf(v -> cal.get(Calendar.MONTH) == Calendar.JUNE
|| cal.get(Calendar.MONTH) == Calendar.JULY
|| cal.get(Calendar.MONTH) == Calendar.AUGUST);
I haven't mastered streams in Java yet so any help and any hints you might have are appreciated!