In this section, you will get the detailed explanation about the equalsIgnoreCase(String Str) method of String class. We are going to use equalsIgnoreCase(String Str) method of String class in Java. The description of the code is given below for the usag
String equalsIgnoreCase(String Str)
In this section, you will get the detailed explanation about the
equalsIgnoreCase(String Str)
method of String class. We are going to use equalsIgnoreCase(String Str)
method of String class in Java. The description of the code is given below for the usage of the method.
Description of the code:
As shown in the example below we have taken three strings i.e. str1, str2 and str3. Then we have applied the equalsIgnoreCase(String Str) method to compare these three strings. This method shows whether two String objects contain the same data, ignoring the case of the letters in the String. Hence we get the following output.
If atleast one of the following is true then only two characters c1 and c2 are considered the same, ignoring case.
- Applying the method Character.toUpperCase(char) to each character produces the same result.
- Applying the method Character.toLowerCase(char) to each character produces the same result.
- The two characters are the same (as compared by the == operator).
Parameters:
anotherString - the String to compare other String.
Returns true if the argument is not null and the Strings are equal, ignoring case. Otherwise returns true.
|
Here is the code of the program:
C:\unique>javac equalsIgnore.java C:\unique>java equalsIgnore "bon voyage" equals "Bon Appetit"? false "bon voyage" equals "Bon Voyage"? true C:\unique> |