Yes as said, you should not be doing this. Probably fix it at source.
But you can certaing look at this.
public class CapsKeyMap
{
public static void main(String[] args)
{
Map<String, String> lcMap = new HashMap<String,String>();
lcMap.put("one","ONE");
lcMap.put("two","TWO");
lcMap.put("three","THREE");
System.out.println("bef " + lcMap);
Set<String> keySet = lcMap.keySet();
String[] it = keySet.toArray(new String[keySet.size()]);
for(String key : it)
{
Object obj = lcMap.get(key);
lcMap.remove(key);
lcMap.put(key.toUpperCase(), (String)obj);
}
System.out.println("Aft " + lcMap);
}
}
You need to take care of the types.
Thanks,
Vijay Venkataraman
Antonio Petrelli wrote:
temp temp ha scritto:
I get this Map from a collection and collection might have 1000 or
more Maps so I first iterate over this collection retrieve the map
and then iterate over this map so creating a new Map for each
iteration is this a good design ?
Surely it is not a good design, but that is up to you. You asked a
thing and I answered. Maybe you have to turn your question inside-out:
Why are you putting keys as non-uppercase strings, when you need it?
Maybe you could implement a java.util.Map in a case-insensitive way,
where the key must be a string, and it does not matter what its keys
case is. But again this is up to you, I cannot do your homework :-P
Ciao
Antonio
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------DISCLAIMER------------------------------
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and
all copies of it from your system, destroy any hard copies of it and
notify the sender. You must not, directly or indirectly, use, disclose,
distribute, print, or copy any part of this message if you are not the
intended recipient.
Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each
reserve the right to monitor all e-mail communications through its
networks.
Any views expressed in this message are those of the
individual sender, except where the message states otherwise and the
sender is authorized to state them to be the views of any such entity.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]