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.
String my_str1="Welcome to plus2net";
System.out.println(my_str1.compareToIgnoreCase("welcome to plus2net")); // 0
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.

The string comparision is done lexicographically ( dictionary order and alphabetical order ).
String my_str1="plus2net";
System.out.println(my_str1.compareToIgnoreCase("welcome")); // -7
Difference between unicode values of p and w is -7.

All String functions


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer