I can't find the problem. Can anyone help me with this one?
public static void removeAllSummerPeople(HashMap<String, Date> map) {
Iterator<HashMap.Entry<String, Date>> iterator = map.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<String, Date> pair = iterator.next();
Date birth = pair.getValue();
int month = birth.getMonth();
if (month == 6 || month == 7 || month ==8){ iterator.remove();
}
//write your code here
}}
Error: The removeAllSummerPeople() method not working
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
27 March 2019, 20:58
Dont know. You should always attach your full code, could be a problem somewhere else:
.
0
Guadalupe Gagnon
27 March 2019, 21:01
Though i am sure that the getMonth method returns an int that is between 0-11 for January-December. Try accounting for this.
0
Thomas
2 April 2019, 19:16
Thank you for your reply. I did a restart with calendar instead of Date and found a solution!
+1