Java string.equalsignorecase () method Usage example tutorial, comparing strings to another string, ignoring case factors.
The java.lang.String.equalsIgnoreCase () method compares a string to another string, ignoring the case factor. Two strings are considered equal when ignoring case, if they are two strings of the same length and the corresponding characters are equal ignoring casing
Statement
The following is a declaration of the Java.lang.String.equalsIgnoreCase () method
public boolean equalsignorecase (String anotherstring)
Parameters
return value
This method returns true if the argument is not NULL, it is equivalent to a string that ignores case, otherwise returns false
Abnormal
Instance
The following example shows the Java.lang.String.equalsIgnoreCase () method used
Package Com.yiibai;import java.lang.*;p ublic class Stringdemo {public static void Main (string[] args) { String s TR1 = "Sachin Tendulkar"; String str2 = "Amrood admin"; String STR3 = "Amrood ADMIN"; Checking for equality with case ignored boolean retval1 = Str2.equalsignorecase (str1); Boolean retval2 = Str2.equalsignorecase (STR3); Prints the return value System.out.println ("str2 is equal to str1 =" + retval1); System.out.println ("str2 is equal to STR3 =" + Retval2);} }
Let's compile and run the above program, which will produce the following results:
STR2 are equal to STR1 = Falsestr2 are equal to STR3 = True
Java String.equalsignorecase () method