• Post Reply Bookmark Topic Watch Topic
  • New Topic

Delete some keys-values from a HashMap  RSS feed

 
Antonis Kaklis
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
I have a little problem. I use a map of type ConcurrentHashMap to store old filenames and renamed filenames
e.g. Map<String,String> renameMap =......
What i want is how could i delete some key-values in my map(based on some criteria)?Not all.

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't have the key strings that you want to remove, you can obtain an iterator() from the Map and remove mappings selectively as you iterate through all mappings.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:you can obtain an iterator() from the Map

Through its entrySet() method yes. Map doesn't have an iterator() method itself (although maybe it should have...).
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Antonis Kaklis
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all!
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!