忽略大小写比较

"aBc".equalsIgnoreCase("ABC")=true;
"aBc".equals("ABC")=false

解决方案 »

  1.   

    忽略字符串的大小写比较两个字符串的值是否相等。
    String a = "abc";
    String b = "ABC";则 boolean result = a.equalsIgnoreCase(b);的返回值是true。Compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length, and corresponding characters in the two strings are equal ignoring case. 
    Two characters c1 and c2 are considered the same, ignoring case if at least one of the following is true: The two characters are the same (as compared by the == operator). 
    Applying the method Character.toUpperCase(char) to each character produces the same result. 
    Applying the method Character.toLowerCase(char) to each character produces the same result.