I need this to be coded in Java and I have a real problem wi
I need this to be coded in Java, and I have a real problem with recursion! PLEASE HELP ME!
Solution
Here is the code for the first problem:
class CompareStrings
{
int compareStrings(String s1, String s2)
{
if(s1.length() == 0 && s2.length() == 0)
return 0;
else if(s2.length() == 0 || s1.charAt(0) > s2.charAt(0))
return 1;
else if(s1.length() == 0 || s1.charAt(0) < s2.charAt(0))
return -1;
else
return compareStrings(s1.substring(1), s2.substring(1));
}
}
