![]() |
VOOZH | about |
In Java, equalsIgnoreCase() method of the String class compares two strings irrespective of the case (lower or upper) of the string. This method returns a boolean value, true if the argument is not null and represents an equivalent String ignoring case, else false.
Input: str1 = "pAwAn";
str2 = "PAWan"
Output: true
Input: str1 = "piwAn";
str2 = "PAWan"
Output: false
Example:
str2 is equal to str1 = true str2 is equal to str3 = false
str2.equalsIgnoreCase(str1);
Here str1 is the string that is supposed to be compared.
Return Value: A boolean value that is true if the argument is not null and it represents an equivalent String ignoring case, else false.
public boolean equalsIgnoreCase(String str) {
return (this == str) ? true
: (str != null)
&& (str.value.length == value.length)
&& regionMatches(true, 0, str, 0, value.length);
}