Не могу понять, почему, после запуска из метода main метода создания map, с соответствующим return map не могу сослаться на этот map и передать его в другой метод или использовать в методе main.
package com.javarush.task.task08.task0816;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.time.LocalDate;
/*
Добрая Зинаида и летние каникулы
*/
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("JANUARY 10 2012"));
map.put("Секундантов", dateFormat.parse("FEBRUARY 11 2012"));
map.put("Тертичный", dateFormat.parse("MARCH 12 2012"));
map.put("Квадратов", dateFormat.parse("APRIL 13 2012"));
map.put("Пентанов", dateFormat.parse("MAY 14 2012"));
map.put("Секстантов", dateFormat.parse("JUNE 15 2012"));
map.put("Септин", dateFormat.parse("JULY 16 2012"));
map.put("Октин", dateFormat.parse("AUGUST 17 2012"));
map.put("Нонин", dateFormat.parse("SEPTEMBER 18 2012"));
map.put("Декартов", dateFormat.parse("OCTOBER 19 2012"));
//напишите тут ваш код
for (Map.Entry<String, Date> pair : map.entrySet()) {
String key = pair.getKey();
Date value = pair.getValue();
//System.out.println(key + " " + value);
}
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();
Date value = pair.getValue();
int month = value.getMonth();
if (month == 5 || month == 6 || month == 7) {
String key = pair.getKey();
System.out.println(key + " " + value);
}
}
}
public static void main(String[] args) throws ParseException {
createMap();
//removeAllSummerPeople(map);
for (Map.Entry<String, Date> pair : map.entrySet()) {
String key = pair.getKey();
Date value = pair.getValue();
int month = value.getMonth();
if (month == 5 || month == 6 || month == 7) {
//String key = pair.getKey();
System.out.println(key + " " + value);
}
}
}
}