String.compareToIgnoreCase() Returns the difference. If both string are equal then 0 is returned.
The output is an integer and the value is here
< 0 : If String1 is less than String2
= 0 : If String1 is equal to String2
< 1 : If String1 is greater than String2
Here are some examples with output.
Note : Unicode value of W is 87 and lower case w is 119 ( difference is -32 ) . As this is case insensitive string comparison the output is 0.
String my_str1="Welcome to plus2net";
System.out.println(my_str1.compareToIgnoreCase("welcome to plus2net")); // 0
The string comparision is done lexicographically ( dictionary order and alphabetical order ).
Difference between unicode values of p and w is -7.
System.out.println(my_str1.compareToIgnoreCase("welcome")); // -7
All String functions
This article is written by plus2net.com team.