Friday, January 16, 2009

Case Insensitive Map : The keys, a String, are case insensitive.

The code...
Map aMap = new CaseInsensitiveMap();
aMap.put("A", "The letter A or a");
aMap.put("b", "The letter B or b");
System.out.println("aMap.get(\"a\") = " + aMap.get("a"));
System.out.println("aMap.get(\"A\") = " + aMap.get("A"));
System.out.println("aMap.get(\"b\") = " + aMap.get("b"));
System.out.println("aMap.get(\"B\") = " + aMap.get("B"));

The results..
aMap.get("a") = The letter A or a
aMap.get("A") = The letter A or a
aMap.get("b") = The letter B or b
aMap.get("B") = The letter B or b
Author: Philip A Senger

No comments:

Post a Comment

Post a Comment