Get integer difference between string just like strcmp
java, string-comparison
Solution
Does Java have any easy intuitive way to do it?
Yes, it does: `java.lang.String` implements `Comparable<String>` interface, with `compareTo` function:
int comparisonResult = a.compareTo(b);
There is also a case-insensitive version:
int comparisonResult = a.compareToIgnoreCase(b);
Problem
I just need a function that will, for two given strings, return negative, positive or zero value. In C, `strcmp` is used: ``` char* a = "Hello"; char* b = "Aargh"; strcmp(a, b); //-1 strcmp(a, a); //0 strcmp(b, a); //1 ``` Does Java have any easy intuitive way to do it, or do I have to use the `Comparator` interface?