Java String compareToIgnoreCase example

Previous
Next
String’s compareToIgnoreCase method is similar to compareTo method. Only difference with compareTo is that it ignores cases.It also compares Strings lexigraphically. Both String get converted to unicode value and then compares.

If you call str1. compareToIgnoreCase(str2)

then if it returns
positive number : str1 is greater than str2
0: str1 is equal to str2
negative number : str1 is smaller than str2

When you run above program, you will get below output:

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog