equalsIgnoreCase method in Java String
equalsIgnoreCase method in Java String
The equalsIgnoreCase() method compares two given strings based on the contents of the string, case insensitive. If the two strings are different it returns false. If two strings are equal it returns true.
Syntax:
public boolean equals(Object anotherObject)
Example:
public class EqualsExample01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s1 = "java";
String s2 = "java";
String s3 = "JAVA";
String s4 = "python";
System.out.println(s1.equalsIgnoreCase(s2));
System.out.println(s1.equalsIgnoreCase(s3));
System.out.println(s1.equalsIgnoreCase(s4));
}
}
Result:

Did you find this article helpful?
Support the author so they can write more quality articles!