14 May String equalsIgnoreCase(String anotherString) method in Java
The boolean equalsIgnoreCase(String anotherString) method in Java compares this String to another String, ignoring case considerations.
Syntax
Let us see the syntax,
boolean equalsIgnoreCase(String anotherString)
Parameters
Let us see the parameters,
- anotherString – This is the String to compare this String against.
Example
The following is an example of boolean equalsIgnoreCase(String anotherString),
public class StudyopediaDemo {
public static void main(String args[]) {
boolean result;
String message1 = new String("Welcome to Studyopedia");
String message2 = new String("Welcome to Studyopedia");
String message3 = new String("WELCOME TO STUDYOPEDIA");
result = message1.equalsIgnoreCase(message2);
System.out.println("Result: " + result );
result = message2.equalsIgnoreCase(message3);
System.out.println("Result: " + result );
}
}
Output
The following is the output,

No Comments