How can I hold a multi-digit card?

I have a MultivaluedMap object, and I want to convert all keys (not values) to uppercase.

I managed to iterate over the object, but I cannot figure out how to reload it.

Any ideas?

+4
source share
2 answers

To expand my comment on Ernest's correct answer, here is how I could implement the remove -and- put solution:

 for (String key : new ArrayList<String>(map.keySet())) { String upper = key.toUpperCase(); for (String value : map.remove(key)) map.add(upper, value); } 
+4
source

You will need to put each modified key / value pair into a new map when processing it. In the end, you can either return a new map by discarding the original, or you can clear() original and copy all the elements from the temporary map back to the original. There will be no better way to do this than that.

+3
source

All Articles