Java中的equalsIgnoreCase()方法如何使用
equalsIgnoreCase()方法是用来比较两个字符串是否是相等,不辨别大小写。
使用方法以下:
```java
String str1 = "Hello";
String str2 = "hello";
// 使用equalsIgnoreCase()方法比较两个字符串是否是相等
boolean isEqual = str1.equalsIgnoreCase(str2);
System.out.println(isEqual); // 输出 true
```
在上面的例子中,str1和str2的值分别为"Hello"和"hello",虽然两个字符串的大小写区分,但是使用equalsIgnoreCase()方法比较时,返回的结果为true,说明两个字符串相等。
TOP