-1

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?

4castle
  • 32,613
  • 11
  • 69
  • 106
user9791370
  • 339
  • 1
  • 10

2 Answers2

0

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.

Isha Agarwal
  • 420
  • 4
  • 12
0

in this case the out are be 1, because H comes after of G