首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

大小写不敏感匹配方法(要求极端高效)

2012-02-19 
求一个大小写不敏感匹配方法(要求极端高效)我写了个低效的.public static boolean isMatch (String input,

求一个大小写不敏感匹配方法(要求极端高效)
我写了个低效的.
public static boolean isMatch (String input, String checkKey) {

boolean result = false;
if (input.equals(checkKey) || input.toLowerCase().equals(checkKey.toLowerCase())) {
result = true;
}
return result;
}

toLowerCase这个方式太低效. 我见过C++处理这类问题有一些高效方式. java 有吗? 或者说java的toLowerCase 已经是被封装过的最高效的方式了?

[解决办法]
input.equalsIgnoreCase(checkKey) ,返回true或false
比你那个高效多了
[解决办法]
楼上正解
[解决办法]
2楼正解

热点排行