Home >Java >javaTutorial >What does equalsignorecase mean in java
The equalsIgnoreCase() method in Java is used to compare two strings, ignoring case. The usage is as follows: accepts a string parameter. Returns true if the two strings are equal (ignoring case); otherwise returns false. Case comparison uses the rules of the current locale. Throws an exception if any parameter is null.
equalsIgnoreCase in Java
In Java, the equalsIgnoreCase() method is used to compare two strings, Case is ignored.
Usage
This method accepts a string parameter and returns a Boolean value:
Grammar
<code class="java">public boolean equalsIgnoreCase(String str)</code>
Description
Example
<code class="java">String str1 = "Hello"; String str2 = "hello"; // 忽略大小写比较 boolean result = str1.equalsIgnoreCase(str2); // 打印结果 System.out.println(result); // 输出 true</code>
Applicable scenarios
equalsIgnoreCase() method is usually used in the following scenarios:
The above is the detailed content of What does equalsignorecase mean in java. For more information, please follow other related articles on the PHP Chinese website!