public static void removeAllSummerPeople(HashMap<String, Date> map) {
Iterator<Map.Entry<String, Date>> iterator = map.entrySet().iterator();//write your code here
while (iterator.hasNext()) {
Map.Entry<String, Date> entry = iterator.next();
if (entry.getValue().getMonth() >= 5 && entry.getValue().getMonth() <= 7) {
iterator.remove();
}
}
}
Why getMonth() method is deprecated ?
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Gellert Varga
17 July 2020, 09:37
I putted this part into my program (task0816), and that worked well at my IDE.
Can You send the whole program? Plus tell me, which requirement was red, or what was the error message.
0
Marek Pasierbek Working at Nexus Polska
17 July 2020, 13:53
Program is ok, it works but Intellij show me information that this method is so old
0
Gellert Varga
17 July 2020, 20:11
All thing of Date class (including all its methods) are deprecated, Java creators said this.
Against that it works well.
The Calendar class is said to be more modern, it is suggested instead of the Date class.
There will be a lesson on this in more detail.
But based on what we’ve learned about it so far, I still can’t suggest better thing and i can't use better thing than many good features/methods in the Date class.
0