equalsIgnoreCase() method is used to compare a string with the specified object, regardless of case.
Syntax
public boolean equalsIgnoreCase(String anotherString)
Parameters
anObject -- with characters String objects to compare against.
Return value
Returns true if the given object is equal to the string; otherwise returns false.
Example
public class Test { public static void main(String args[]) { String Str1 = new String("runoob"); String Str2 = Str1; String Str3 = new String("runoob"); String Str4 = new String("RUNOOB"); boolean retVal; retVal = Str1.equals( Str2 ); System.out.println("返回值 = " + retVal ); retVal = Str3.equals( Str4); System.out.println("返回值 = " + retVal ); retVal = Str1.equalsIgnoreCase( Str4 ); System.out.println("返回值 = " + retVal ); }}
The execution result of the above program is:
返回值 = true 返回值 = false 返回值 = true
[Related recommendations]
1. Detailed explanation of Java The difference between equals(), equalsIgnoreCase() and ==
2. Share the difference between equals and equalsignorecase in Java and their usage example tutorial
3 . Image and text examples of equalsIgnoreCase method in java
The above is the detailed content of Introducing Java equalsIgnoreCase() method examples. For more information, please follow other related articles on the PHP Chinese website!