如何使我的字符串比较不区分大小写?
该equalsIgnoreCase()方法将此字符串与指定对象进行比较。当且仅当参数不为null并且是一个String对象,表示与此对象相同的字符序列时,结果为true。
示例
public class Sample {
public static void main(String args[]) {
String Str1 = new String("This is really not immutable!!");
String Str2 = Str1;
String Str3 = new String("THIS IS REALLY NOT IMMUTABLE!!");
boolean retVal;
retVal = Str1.equalsIgnoreCase(Str2);
System.out.println("Returned Value = " + retVal );
retVal = Str1.equalsIgnoreCase( Str3 );
System.out.println("Returned Value = " + retVal );
}
}输出结果
Returned Value = true Returned Value = true
热门推荐
10 简短创意祝福语有什么
11 毕业祝福语简短英语小学
12 新人结婚父母祝福语简短
13 恭喜订婚的祝福语简短
14 祝福语勤奋大全简短英语
15 给老板祝福语简短精辟
16 简短佛教新年祝福语大全
17 朋友节最简短祝福语
18 祝女儿出嫁简短祝福语