I am trying to write a method that uses recursion to compare the strings str1 and str2 and determine which of them comes first alphabetically (i.e., according to the ordering used for words in a dictionary).
If str1
comes first alphabetically, the method should return int 1
.
If str2
comes first alphabetically, the method should return the int 2
.
If the two strings are the same, the method should return the int 0
.
I know that there is a compareTo method in the Java API but i would like to know how to do this without this
This is what i have so far but i m not entirely sure how to proceeded
} if (str1.length().equals(str2.length()))
return 0;
} else {
(str.substring(1, str.length()));
Any ideas would be greatly appreciated