可能重复:
不区分大小写的字符串作为 HashMap 键
我有一个 Hashmap,其中一个字符串作为键,一个整数作为值。现在,我使用 get 方法来获取值,其中字符串与键值匹配。
HashMap<String,Integer> map= new HashMap<String,Integer>();
// Populate the map
System.out.println(map.get("mystring"));
我希望这个字符串比较不区分大小写。反正我能做到吗?
例如,我希望它在以下情况下返回相同的结果:
map.get("hello");
map.get("HELLO");
map.get("Hello");