class CaseImap extends HashMap<String, Object>
{
// Overriding get method
public String get(String key)
{
return (String)super.get(key.toLowerCase());
}
// Overriding put method
public Object put(String key, Object value)
{
return super.put(key.toLowerCase(), value);
}
}
Showing posts with label interview question. Show all posts
Showing posts with label interview question. Show all posts
Saturday, December 4, 2010
How to create Case Insensitive Map in Java
In order to create case insensitive map, just extend HashMap class and override get and put method. Using the below code you can give keys irrespective of case.
Subscribe to:
Posts (Atom)