Given is a simple example on equalsIgnoreCase() method in Java

equalsignorecase() method works similar to equals() method in Java.. the only difference is that equalsignorecase() method simply ignore the case semstivity and examines without considering it. For examples, equalsignorecase() method considere both "java tutorial" and "JAVA TUTORIAL" equals.

Syntax for string.equalsignorecase() method

public boolean equalsIgnoreCase(String anotherString)

java.lang.string.equalsignorecase() method returns "true" if the strings are not empty and of equal lengths with similar coresponding characters...otherwise it returns false.

a simple example of equalsignorecase method in java:

public static void main(String[] args){

String str1 = "Java Tutorials";

String str2 = "Tutorials in Java";

String str3 = "JAVA TUTORIALS";

boolean equals1 = str1.equalsIgnoreCase(str2);

boolean equals2 = str1.equalsIgnoreCase(str3);

System.out.println("\"" + str1 + "\" is equals to \""
+ str2 +
"\" - " + equals1);

System.out.println("\"" + str1 + "\" is equals to \""
+ str3 +
"\" - " + equals2);


the output is:

"Java Tutorials" is equals to "Tutorials in Java" - false

"Java Tutorials" is equals to "JAVA TUTORIALS" - true

Related Links

String equalsIgnoreCase(String Str)


Share on Google+Share on Google+


Posted on: March 17, 2005 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: java.lang.string.equalsignorecase  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image