移除Map中指定的键值对

// map中key(键)的迭代器对象
Iterator<String> iterator = myMap.keySet().iterator();
while (iterator.hasNext()){// 循环取键值进行判断
String key = iterator.next();// 键
if(key.startsWith("week")){
iterator.remove();// 移除map中以week字符开头的键对应的键值对
}
if(key.startsWith("lessonNo")){
iterator.remove();// 移除map中以lessonNo字符开头的键对应的键值对
}
}



来源:https://blog.csdn.net/qq_37584445/article/details/88681622
posted @ 2020-02-20 15:44  嗝屁的博客  阅读(5400)  评论(0)    收藏  举报