移除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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM