View Single Post
  #3 (permalink)  
Old 03-09-2008, 06:55 PM
amexudo amexudo is offline
Member
 
Join Date: Mar 2008
Posts: 2
amexudo is on a distinguished road
code
public static int myCompare(String s1, String s2){

if (s1.charAt(0)==s2.charAt(0)){
if (s1.length() == 1 && s2.length()!= 1)
return 2;
else
if (s1.length() != 1 && s2.length() ==1)
return 1;
else
if (s1.length()==1 && s2.length() == 1)
return 0;
else
return myCompare(s1.substring(1),s2.substring(1));
}
else {
if (s1.charAt(0)<s2.charAt(0))
return 2;
else
return 1;
}
}



this is what i've done. i think it's right, didn't find any problem till now.
thanks again for your help!
Reply With Quote