Let's say i write this:
String a = "Hello";
String b = "Goodbye";
int compare = a.compareToIgnoreCase(b);
System.out.println(compare);
What will the printout be?
Let's say i write this:
String a = "Hello";
String b = "Goodbye";
int compare = a.compareToIgnoreCase(b);
System.out.println(compare);
What will the printout be?
It compares character by character for each string.
For example in this case When a = "hello" and b = "Goodbye"
It checks first character of a with first character of b and computes the relative difference, if it's same then it checks the next character, else it computes the difference and returns it.
If string a is greater than string b it returns a positive difference else it returns a negative difference.