两个字符串比较,不区分大小写,如,比较 abcde 和 ABCDE 是否相等,如果用equals,是区分大小写的,会返回false;如果用 equalsIgnoreCases则会返回true

String strA = "abcde";

String strB = "ABCDE";

boolean result = strA.equalsIgnoreCase(strB);

System.out.pring(result);

执行结果为 :true

 

String strA = "abcde";

String strB = "ABCde";

boolean result = strA.equalsIgnoreCase(strB);

System.out.pring(result);

执行结果为 :true