На 29 строке компилятор выдаёт ошибку Object cannot be converted to Entry<String,Date>
Map.Entry<String, Date> entry = mapIterator.next();
Замучился совсем с этими hashmap и итераторами, в чём проблема? Уже 3 день пытаюсь решить.
package com.javarush.task.task08.task0816;
import java.text.*;
import java.util.*;
/*
Добрая Зинаида и летние каникулы
*/
public class Solution {
public static HashMap<String, Date> createMap() throws ParseException {
DateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
Map<String, Date> map = new HashMap<>();
map.put("Stallone", df.parse("JUNE 1 1980"));
map.put("1", df.parse("JANUARY 1 1980"));
map.put("2", df.parse("FEBRUARY 1 1980"));
map.put("3", df.parse("MARCH 1 1980"));
map.put("4", df.parse("APRIL 1 1980"));
map.put("5", df.parse("MAY 1 1980"));
map.put("6", df.parse("JUNE 1 1980"));
map.put("7", df.parse("JULY 1 1980"));
map.put("8", df.parse("AUGUST 1 1980"));
map.put("9", df.parse("SEPTEMBER 1 1980"));
}
public static void removeAllSummerPeople(HashMap<String, Date> map) throws Exception {
Iterator mapIterator = map.entrySet().iterator();
while (mapIterator.hasNext()) {
Map.Entry<String, Date> entry = mapIterator.next();
System.out.println("Key:" + entry.getKey());
System.out.println("Value:" + entry.getValue());
}
}
public static void main(String[] args) throws Exception {
}
}