I have a Map<String,String>
with large number of key values pairs. Now I want to remove selected keys from that Map
. Following code shows what I did to achieve that.
Set keySet = new HashSet(); //I added keys to keySet which I want to remove.
Then :
Iterator entriesIterator = keySet.iterator();
while (entriesIterator.hasNext()) {
map.remove( entriesIterator.next().toString());
}
This is working fine. What would be the better approach?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…