equalsIgnoreCase()方法是用来比较两个字符串是否相等,不区分大小写。
使用方法如下:
String str1 = "Hello";
String str2 = "hello";
// 使用equalsIgnoreCase()方法比较两个字符串是否相等
boolean isEqual = str1.equalsIgnoreCase(str2);
System.out.println(isEqual); // 输出 true
在上面的例子中,str1和str2的值分别为"Hello"和"hello",虽然两个字符串的大小写不同,但是使用equalsIgnoreCase()方法比较时,返回的结果为true,说明两个字符串相等。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>