Map with case insensitive keys in Spring utils.

Keys in the java. util. HashMap are case sensitive. It means you can have both “abc” and “ABC” as keys in the same map.

There are many way around for this issue , but in Spring Utils we already have a LinkedCaseInsensitiveMap for case insensitive keys.

      public static void main(String args[]) {
	   Map<String, Object> customized=new LinkedCaseInsensitiveMap<Object>();;
	   customized.put("HELLO1", "Hello,how do you do?");
	   Map<String, Object> customized2=new HashMap<String,Object>();;
	   customized.put("HELLO1", "Hello,how do you do?");
	   System.out.println("Case sensitive "+customized2.get("hello1"));
	   System.out.println("Case Insensitive "+customized.get("hello1"));

o/p of the above —
Case sensitive null
Case Insensitive Hello,how do you do?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: